diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw
index b2133af1816..a0a653927e3 100644
--- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw
+++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw
@@ -709,6 +709,9 @@
Successfully exported terminal content
+
+ Find
+
Plain Text
diff --git a/src/cascadia/TerminalApp/TabManagement.cpp b/src/cascadia/TerminalApp/TabManagement.cpp
index d744cb09fd2..47cfa70d7b2 100644
--- a/src/cascadia/TerminalApp/TabManagement.cpp
+++ b/src/cascadia/TerminalApp/TabManagement.cpp
@@ -209,6 +209,16 @@ namespace winrt::TerminalApp::implementation
}
});
+ newTabImpl->FindRequested([weakTab, weakThis{ get_weak() }]() {
+ auto page{ weakThis.get() };
+ auto tab{ weakTab.get() };
+
+ if (page && tab)
+ {
+ page->_Find();
+ }
+ });
+
auto tabViewItem = newTabImpl->TabViewItem();
_tabView.TabItems().Append(tabViewItem);
diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp
index c5c6cd2f5b2..64cbd16dc4f 100644
--- a/src/cascadia/TerminalApp/TerminalTab.cpp
+++ b/src/cascadia/TerminalApp/TerminalTab.cpp
@@ -1273,6 +1273,23 @@ namespace winrt::TerminalApp::implementation
exportTabMenuItem.Icon(exportTabSymbol);
}
+ Controls::MenuFlyoutItem findMenuItem;
+ {
+ // "Split Tab"
+ Controls::FontIcon findSymbol;
+ findSymbol.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
+ findSymbol.Glyph(L"\xF78B"); // SearchMedium
+
+ findMenuItem.Click([weakThis](auto&&, auto&&) {
+ if (auto tab{ weakThis.get() })
+ {
+ tab->_FindRequestedHandlers();
+ }
+ });
+ findMenuItem.Text(RS_(L"FindText"));
+ findMenuItem.Icon(findSymbol);
+ }
+
// Build the menu
Controls::MenuFlyout contextMenuFlyout;
Controls::MenuFlyoutSeparator menuSeparator;
@@ -1281,6 +1298,7 @@ namespace winrt::TerminalApp::implementation
contextMenuFlyout.Items().Append(duplicateTabMenuItem);
contextMenuFlyout.Items().Append(splitTabMenuItem);
contextMenuFlyout.Items().Append(exportTabMenuItem);
+ contextMenuFlyout.Items().Append(findMenuItem);
contextMenuFlyout.Items().Append(menuSeparator);
// GH#5750 - When the context menu is dismissed with ESC, toss the focus
@@ -1291,7 +1309,7 @@ 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())
+ if (!tab->_headerControl.InRename() && !tab->GetActiveTerminalControl().SearchBoxEditInFocus())
{
tab->_RequestFocusActiveControlHandlers();
}
diff --git a/src/cascadia/TerminalApp/TerminalTab.h b/src/cascadia/TerminalApp/TerminalTab.h
index 09922f2f1ad..f5ea3b0cd41 100644
--- a/src/cascadia/TerminalApp/TerminalTab.h
+++ b/src/cascadia/TerminalApp/TerminalTab.h
@@ -102,6 +102,7 @@ namespace winrt::TerminalApp::implementation
WINRT_CALLBACK(TabRaiseVisualBell, winrt::delegate<>);
WINRT_CALLBACK(DuplicateRequested, winrt::delegate<>);
WINRT_CALLBACK(SplitTabRequested, winrt::delegate<>);
+ WINRT_CALLBACK(FindRequested, winrt::delegate<>);
WINRT_CALLBACK(ExportTabRequested, winrt::delegate<>);
TYPED_EVENT(TaskbarProgressChanged, IInspectable, IInspectable);
diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp
index 3a0f6cba84d..fdb19c31acf 100644
--- a/src/cascadia/TerminalControl/TermControl.cpp
+++ b/src/cascadia/TerminalControl/TermControl.cpp
@@ -197,6 +197,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
}
+ // Method Description:
+ // Find if search box text edit currently is in focus
+ // Return Value:
+ // - true, if search box text edit is in focus
+ bool TermControl::SearchBoxEditInFocus() const
+ {
+ if (!_searchBox)
+ {
+ return false;
+ }
+
+ return _searchBox->TextBox().FocusState() == FocusState::Keyboard;
+ }
+
// Method Description:
// - Search text in text buffer. This is triggered if the user click
// search button or press enter.
diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h
index c76c4b58703..656e1f68451 100644
--- a/src/cascadia/TerminalControl/TermControl.h
+++ b/src/cascadia/TerminalControl/TermControl.h
@@ -90,6 +90,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void SearchMatch(const bool goForward);
+ bool SearchBoxEditInFocus() const;
+
bool OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down);
bool OnMouseWheel(const Windows::Foundation::Point location, const int32_t delta, const bool leftButtonDown, const bool midButtonDown, const bool rightButtonDown);
diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl
index b235962a73f..8633931c7df 100644
--- a/src/cascadia/TerminalControl/TermControl.idl
+++ b/src/cascadia/TerminalControl/TermControl.idl
@@ -62,6 +62,7 @@ namespace Microsoft.Terminal.Control
void ScrollViewport(Int32 viewTop);
void CreateSearchBoxControl();
+ Boolean SearchBoxEditInFocus();
void SearchMatch(Boolean goForward);