Skip to content

Commit f89368c

Browse files
committed
[PARENT] try to use GetActiveTerminalControl less in TerminalTab
(cherry picked from commit 262d95a)
1 parent 5582e1b commit f89368c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/cascadia/TerminalApp/TerminalTab.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ namespace winrt::TerminalApp::implementation
188188
return nullptr;
189189
}
190190

191+
IPaneContent TerminalTab::GetActiveContent() const
192+
{
193+
return _activePane ? _activePane->GetContent() : nullptr;
194+
}
195+
191196
// Method Description:
192197
// - Called after construction of a Tab object to bind event handlers to its
193198
// associated Pane and TermControl objects
@@ -371,8 +376,8 @@ namespace winrt::TerminalApp::implementation
371376
{
372377
return RS_(L"MultiplePanes");
373378
}
374-
const auto lastFocusedControl = GetActiveTerminalControl();
375-
return lastFocusedControl ? lastFocusedControl.Title() : L"";
379+
const auto activeContent = GetActiveContent();
380+
return activeContent ? activeContent.Title() : L"";
376381
}
377382

378383
// Method Description:
@@ -1433,7 +1438,12 @@ namespace winrt::TerminalApp::implementation
14331438
// GH#10112 - if we're opening the tab renamer, don't
14341439
// immediately toss focus to the control. We don't want to steal
14351440
// focus from the tab renamer.
1436-
if (!tab->_headerControl.InRename() && !tab->GetActiveTerminalControl().SearchBoxEditInFocus())
1441+
const auto& terminalControl{ tab->GetActiveTerminalControl() }; // maybe null
1442+
// If we're
1443+
// * NOT in a rename
1444+
// * AND (the content isn't a TermControl, OR the term control doesn't have focus in the search box)
1445+
if (!tab->_headerControl.InRename() &&
1446+
(terminalControl == nullptr || !terminalControl.SearchBoxEditInFocus()))
14371447
{
14381448
tab->_RequestFocusActiveControlHandlers();
14391449
}

src/cascadia/TerminalApp/TerminalTab.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace winrt::TerminalApp::implementation
2525

2626
winrt::Microsoft::Terminal::Control::TermControl GetActiveTerminalControl() const;
2727
winrt::Microsoft::Terminal::Settings::Model::Profile GetFocusedProfile() const noexcept;
28+
winrt::TerminalApp::IPaneContent GetActiveContent() const;
2829

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

0 commit comments

Comments
 (0)