Skip to content

Commit a512ddd

Browse files
Don-VitoDHowett
authored andcommitted
8247: Custom key bindings are broken for tab navigation (#8250)
There are two code paths for Ctrl+Tab and for everything else: Ctrl + Tab is working perfectly * On the first tab navigation TerminalPage::_SelectNextTab resets the tab commands, and since palette is not visible selects the relevant tab index * On the second navigation Ctrl+Tab is intercepted by CommandPalette::_previewKeyDownHandler and everything works fine But with custom binding things are screwed: * On the first tab navigation TerminalPage::_SelectNextTab resets the tab commands, and since palette is not visible selects the relevant tab index * On the second navigation keys are not intercepted and thus TerminalPage::_SelectNextTab is called again. It resets the commands, but now since the palette is visible we simply invoke CommandPalette::SelectNextItem. Which in turn misbehaves because no item is selected. The approach for the solution is not to reset anything if the command palette is already open. * Manual testing of both custom and non-custom bindings with different amount of tabs. Closes #8247 (cherry picked from commit 0437fe9)
1 parent c2bc927 commit a512ddd

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,14 @@ namespace winrt::TerminalApp::implementation
12181218
// - Sets focus to the tab to the right or left the currently selected tab.
12191219
void TerminalPage::_SelectNextTab(const bool bMoveRight)
12201220
{
1221+
if (CommandPalette().Visibility() == Visibility::Visible)
1222+
{
1223+
// If the tab switcher is currently open, don't change its mode.
1224+
// Just select the new tab.
1225+
CommandPalette().SelectNextItem(bMoveRight);
1226+
return;
1227+
}
1228+
12211229
if (_settings.GlobalSettings().UseTabSwitcher())
12221230
{
12231231
CommandPalette().SetTabActions(_mruTabActions);
@@ -1227,15 +1235,10 @@ namespace winrt::TerminalApp::implementation
12271235
uint32_t tabCount = _mruTabActions.Size();
12281236
auto newTabIndex = ((tabCount + (bMoveRight ? 1 : -1)) % tabCount);
12291237

1230-
if (CommandPalette().Visibility() == Visibility::Visible)
1231-
{
1232-
CommandPalette().SelectNextItem(bMoveRight);
1233-
}
1234-
else
1235-
{
1236-
CommandPalette().EnableTabSwitcherMode(false, newTabIndex);
1237-
CommandPalette().Visibility(Visibility::Visible);
1238-
}
1238+
// Otherwise, set up the tab switcher in the selected mode, with
1239+
// the given ordering, and make it visible.
1240+
CommandPalette().EnableTabSwitcherMode(false, newTabIndex);
1241+
CommandPalette().Visibility(Visibility::Visible);
12391242
}
12401243
else if (auto index{ _GetFocusedTabIndex() })
12411244
{

0 commit comments

Comments
 (0)