Skip to content

Commit

Permalink
Allow ClosePane to close the Settings UI (microsoft#8903)
Browse files Browse the repository at this point in the history
This is an extension of microsoft#8885. A lot of users have grown accustomed to
using `closePane` to close a tab. This adds `closePane` to the list of
keybindings accepted by microsoft#8885, and modifies the `closePane` code to
close the Settings UI if we are in a `SettingsTab`.

## References

microsoft#6800: Settings UI Epic
microsoft#8885: PR - Settings UI should respect key bindings (temporary solution)
microsoft#8882: Issue - Settings UI should respect key bindings
  • Loading branch information
carlos-zamora authored and mpela81 committed Jan 28, 2021
1 parent a3be23c commit 58668f6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ namespace winrt::TerminalApp::implementation

winrt::Microsoft::Terminal::TerminalControl::KeyChord kc{ ctrlDown, altDown, shiftDown, static_cast<int32_t>(key) };
const auto actionAndArgs = _settings.KeyMap().TryLookup(kc);
if (actionAndArgs && (actionAndArgs.Action() == ShortcutAction::CloseTab || actionAndArgs.Action() == ShortcutAction::NextTab || actionAndArgs.Action() == ShortcutAction::PrevTab))
if (actionAndArgs && (actionAndArgs.Action() == ShortcutAction::CloseTab || actionAndArgs.Action() == ShortcutAction::NextTab || actionAndArgs.Action() == ShortcutAction::PrevTab || actionAndArgs.Action() == ShortcutAction::ClosePane))
{
_actionDispatch->DoAction(actionAndArgs);
e.Handled(true);
Expand Down Expand Up @@ -1554,6 +1554,13 @@ namespace winrt::TerminalApp::implementation
_UnZoomIfNeeded();
terminalTab->ClosePane();
}
else if (auto index{ _GetFocusedTabIndex() })
{
if (_tabs.GetAt(*index).try_as<TerminalApp::SettingsTab>())
{
_RemoveTabViewItemByIndex(*index);
}
}
}

// Method Description:
Expand Down

0 comments on commit 58668f6

Please sign in to comment.