diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 7d1e1178ddb..43fa9630a6a 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -1228,4 +1228,17 @@ namespace winrt::TerminalApp::implementation args.Handled(handled); } } + + void TerminalPage::_HandleRestartConnection(const IInspectable& /*sender*/, + const ActionEventArgs& args) + { + if (const auto activeTab{ _GetFocusedTabImpl() }) + { + if (const auto activePane{ activeTab->GetActivePane() }) + { + _restartPaneConnection(activePane); + } + } + args.Handled(true); + } } diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index c4561e9364c..99a1fdafde9 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2979,18 +2979,20 @@ namespace winrt::TerminalApp::implementation original->SetActive(); } - resultPane->RestartTerminalRequested([this](const auto& pane) { - auto connection = _duplicateConnectionForRestart(pane); - if (connection) - { - pane->GetTerminalControl().Connection(connection); - connection.Start(); - } - }); + resultPane->RestartTerminalRequested({ get_weak(), &TerminalPage::_restartPaneConnection }); return resultPane; } + void TerminalPage::_restartPaneConnection(const std::shared_ptr& pane) + { + if (const auto& connection{ _duplicateConnectionForRestart(pane) }) + { + pane->GetTerminalControl().Connection(connection); + connection.Start(); + } + } + // Method Description: // - Sets background image and applies its settings (stretch, opacity and alignment) // - Checks path validity diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index da694f50ed5..867e93eece3 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -295,6 +295,7 @@ namespace winrt::TerminalApp::implementation void _CreateNewTabFromPane(std::shared_ptr pane, uint32_t insertPosition = -1); winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection _CreateConnectionFromSettings(Microsoft::Terminal::Settings::Model::Profile profile, Microsoft::Terminal::Settings::Model::TerminalSettings settings, const bool inheritCursor); winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection _duplicateConnectionForRestart(std::shared_ptr pane); + void _restartPaneConnection(const std::shared_ptr& pane); winrt::fire_and_forget _OpenNewWindow(const Microsoft::Terminal::Settings::Model::NewTerminalArgs newTerminalArgs); diff --git a/src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp b/src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp index 8b5613bd006..3efeb81d5b7 100644 --- a/src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp @@ -90,6 +90,7 @@ static constexpr std::string_view ToggleBlockSelectionKey{ "toggleBlockSelection static constexpr std::string_view SwitchSelectionEndpointKey{ "switchSelectionEndpoint" }; static constexpr std::string_view ColorSelectionKey{ "experimental.colorSelection" }; static constexpr std::string_view ExpandSelectionToWordKey{ "expandSelectionToWord" }; +static constexpr std::string_view RestartConnectionKey{ "restartConnection" }; static constexpr std::string_view ActionKey{ "action" }; @@ -418,6 +419,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation { ShortcutAction::SwitchSelectionEndpoint, RS_(L"SwitchSelectionEndpointCommandKey") }, { ShortcutAction::ColorSelection, MustGenerate }, { ShortcutAction::ExpandSelectionToWord, RS_(L"ExpandSelectionToWordCommandKey") }, + { ShortcutAction::RestartConnection, RS_(L"RestartConnectionKey") }, }; }(); diff --git a/src/cascadia/TerminalSettingsModel/AllShortcutActions.h b/src/cascadia/TerminalSettingsModel/AllShortcutActions.h index fd6f1a080e2..b6a2228b88c 100644 --- a/src/cascadia/TerminalSettingsModel/AllShortcutActions.h +++ b/src/cascadia/TerminalSettingsModel/AllShortcutActions.h @@ -103,7 +103,8 @@ ON_ALL_ACTIONS(SwitchSelectionEndpoint) \ ON_ALL_ACTIONS(ColorSelection) \ ON_ALL_ACTIONS(ExpandSelectionToWord) \ - ON_ALL_ACTIONS(CloseOtherPanes) + ON_ALL_ACTIONS(CloseOtherPanes) \ + ON_ALL_ACTIONS(RestartConnection) #define ALL_SHORTCUT_ACTIONS_WITH_ARGS \ ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \ diff --git a/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw index a64259f182d..1d6502c1f7a 100644 --- a/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw @@ -675,6 +675,9 @@ Close all other panes + + Restart connection + Select next command output diff --git a/src/cascadia/TerminalSettingsModel/defaults.json b/src/cascadia/TerminalSettingsModel/defaults.json index c57f6320c6c..daf9827edf3 100644 --- a/src/cascadia/TerminalSettingsModel/defaults.json +++ b/src/cascadia/TerminalSettingsModel/defaults.json @@ -449,6 +449,7 @@ { "command": { "action": "movePane", "index": 6 } }, { "command": { "action": "movePane", "index": 7 } }, { "command": { "action": "movePane", "index": 8 } }, + { "command": "restartConnection" }, // Clipboard Integration { "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+shift+c" },