Skip to content

Commit

Permalink
guard some GetActiveTerminalControl calls
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Nov 16, 2021
1 parent 25947c2 commit 056446c
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,21 +1416,24 @@ namespace winrt::TerminalApp::implementation
{
if (const auto terminalTab{ _GetFocusedTabImpl() })
{
uint32_t realRowsToScroll;
if (rowsToScroll == nullptr)
if (const auto& termControl{ terminalTab->GetActiveTerminalControl() })
{
// The magic value of WHEEL_PAGESCROLL indicates that we need to scroll the entire page
realRowsToScroll = _systemRowsToScroll == WHEEL_PAGESCROLL ?
terminalTab->GetActiveTerminalControl().ViewHeight() :
_systemRowsToScroll;
}
else
{
// use the custom value specified in the command
realRowsToScroll = rowsToScroll.Value();
uint32_t realRowsToScroll;
if (rowsToScroll == nullptr)
{
// The magic value of WHEEL_PAGESCROLL indicates that we need to scroll the entire page
realRowsToScroll = _systemRowsToScroll == WHEEL_PAGESCROLL ?
termControl.ViewHeight() :
_systemRowsToScroll;
}
else
{
// use the custom value specified in the command
realRowsToScroll = rowsToScroll.Value();
}
auto scrollDelta = _ComputeScrollDelta(scrollDirection, realRowsToScroll);
terminalTab->Scroll(scrollDelta);
}
auto scrollDelta = _ComputeScrollDelta(scrollDirection, realRowsToScroll);
terminalTab->Scroll(scrollDelta);
}
}

Expand Down Expand Up @@ -2093,8 +2096,10 @@ namespace winrt::TerminalApp::implementation
if (warnMultiLine)
{
const auto focusedTab = _GetFocusedTabImpl();
const auto& termControl{ focusedTab->GetActiveTerminalControl() };
// Do not warn about multi line pasting if the current tab has bracketed paste enabled.
warnMultiLine = warnMultiLine && !focusedTab->GetActiveTerminalControl().BracketedPasteEnabled();
warnMultiLine = warnMultiLine &&
(termControl && !termControl.BracketedPasteEnabled());
}

// We have to initialize the dialog here to be able to change the text of the text block within it
Expand Down Expand Up @@ -2402,11 +2407,14 @@ namespace winrt::TerminalApp::implementation
// TODO GH#5047 If we cache the NewTerminalArgs, we no longer need to do this.
profile = GetClosestProfileForDuplicationOfProfile(profile);
controlSettings = TerminalSettings::CreateWithProfile(_settings, profile, *_bindings);
const auto workingDirectory = focusedTab->GetActiveTerminalControl().WorkingDirectory();
const auto validWorkingDirectory = !workingDirectory.empty();
if (validWorkingDirectory)
if (const auto& control{ focusedTab->GetActiveTerminalControl() })
{
controlSettings.DefaultSettings().StartingDirectory(workingDirectory);
const auto workingDirectory = control.WorkingDirectory();
const auto validWorkingDirectory = !workingDirectory.empty();
if (validWorkingDirectory)
{
controlSettings.DefaultSettings().StartingDirectory(workingDirectory);
}
}
}
}
Expand Down

1 comment on commit 056446c

@github-actions

This comment was marked as outdated.

Please sign in to comment.