Skip to content

Commit

Permalink
Ensure export and find tab context menu items work for unfocused tabs (
Browse files Browse the repository at this point in the history
…#14673)

## Summary of the Pull Request
Updates the tab event handling so that the "Export Text" and "Find" tab context menu items work when a tab isn't focused.

## PR Checklist
* [x] Closes #13948
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

## Validation Steps Performed
Manually tested.
  • Loading branch information
ianjoneill authored Jan 16, 2023
1 parent d326496 commit f3439e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,10 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_HandleFind(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
_Find();
if (const auto activeTab{ _GetFocusedTabImpl() })
{
_Find(*activeTab);
}
args.Handled(true);
}

Expand Down
9 changes: 5 additions & 4 deletions src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ namespace winrt::TerminalApp::implementation

if (page && tab)
{
// Passing null args to the ExportBuffer handler will default it
// to prompting for the path
page->_HandleExportBuffer(nullptr, nullptr);
// Passing empty string as the path to export tab will make it
// prompt for the path
page->_ExportTab(*tab, L"");
}
});

Expand All @@ -206,7 +206,8 @@ namespace winrt::TerminalApp::implementation

if (page && tab)
{
page->_Find();
page->_SetFocusedTab(*tab);
page->_Find(*tab);
}
});

Expand Down
10 changes: 5 additions & 5 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3160,15 +3160,15 @@ namespace winrt::TerminalApp::implementation

// Method Description:
// - Called when the user tries to do a search using keybindings.
// This will tell the current focused terminal control to create
// a search box and enable find process.
// This will tell the active terminal control of the passed tab
// to create a search box and enable find process.
// Arguments:
// - <none>
// - tab: the tab where the search box should be created
// Return Value:
// - <none>
void TerminalPage::_Find()
void TerminalPage::_Find(const TerminalTab& tab)
{
if (const auto& control{ _GetActiveControl() })
if (const auto& control{ tab.GetActiveTerminalControl() })
{
control.CreateSearchBoxControl();
}
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ namespace winrt::TerminalApp::implementation
void _OnCommandLineExecutionRequested(const IInspectable& sender, const winrt::hstring& commandLine);
void _OnSwitchToTabRequested(const IInspectable& sender, const winrt::TerminalApp::TabBase& tab);

void _Find();
void _Find(const TerminalTab& tab);

winrt::Microsoft::Terminal::Control::TermControl _InitControl(const winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult& settings,
const winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection& connection);
Expand Down

0 comments on commit f3439e2

Please sign in to comment.