Skip to content

Commit

Permalink
[PARENT] try to use GetActiveTerminalControl less in TerminalTab
Browse files Browse the repository at this point in the history
(cherry picked from commit 262d95a)
  • Loading branch information
zadjii-msft committed Jul 20, 2023
1 parent 5582e1b commit f89368c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ namespace winrt::TerminalApp::implementation
return nullptr;
}

IPaneContent TerminalTab::GetActiveContent() const
{
return _activePane ? _activePane->GetContent() : nullptr;
}

// Method Description:
// - Called after construction of a Tab object to bind event handlers to its
// associated Pane and TermControl objects
Expand Down Expand Up @@ -371,8 +376,8 @@ namespace winrt::TerminalApp::implementation
{
return RS_(L"MultiplePanes");
}
const auto lastFocusedControl = GetActiveTerminalControl();
return lastFocusedControl ? lastFocusedControl.Title() : L"";
const auto activeContent = GetActiveContent();
return activeContent ? activeContent.Title() : L"";
}

// Method Description:
Expand Down Expand Up @@ -1433,7 +1438,12 @@ namespace winrt::TerminalApp::implementation
// GH#10112 - if we're opening the tab renamer, don't
// immediately toss focus to the control. We don't want to steal
// focus from the tab renamer.
if (!tab->_headerControl.InRename() && !tab->GetActiveTerminalControl().SearchBoxEditInFocus())
const auto& terminalControl{ tab->GetActiveTerminalControl() }; // maybe null
// If we're
// * NOT in a rename
// * AND (the content isn't a TermControl, OR the term control doesn't have focus in the search box)
if (!tab->_headerControl.InRename() &&
(terminalControl == nullptr || !terminalControl.SearchBoxEditInFocus()))
{
tab->_RequestFocusActiveControlHandlers();
}
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace winrt::TerminalApp::implementation

winrt::Microsoft::Terminal::Control::TermControl GetActiveTerminalControl() const;
winrt::Microsoft::Terminal::Settings::Model::Profile GetFocusedProfile() const noexcept;
winrt::TerminalApp::IPaneContent GetActiveContent() const;

void Focus(winrt::Windows::UI::Xaml::FocusState focusState) override;

Expand Down

0 comments on commit f89368c

Please sign in to comment.