From a31e7131986dafa89cb5adb9b3b74ecc8e68487d Mon Sep 17 00:00:00 2001 From: Michelle Tan <41475767+MichelleTanPY@users.noreply.github.com> Date: Thu, 20 Aug 2020 22:58:13 +0100 Subject: [PATCH] Make sure we check to profile shortcuts with an index >9 (#7344) Closes #7325 (cherry picked from commit 6f991d312e35d294a13fbce0e7a03bdc896e2ec1) --- src/cascadia/TerminalApp/TerminalPage.cpp | 33 +++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index b68986f93c7..f84863e4e74 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -405,25 +405,22 @@ namespace winrt::TerminalApp::implementation const auto& profile = _settings->GetProfiles()[profileIndex]; auto profileMenuItem = WUX::Controls::MenuFlyoutItem{}; - // add the keyboard shortcuts for the first 9 profiles - if (profileIndex < 9) + // Add the keyboard shortcuts based on the number of profiles defined + // Look for a keychord that is bound to the equivalent + // NewTab(ProfileIndex=N) action + auto actionAndArgs = winrt::make_self(); + actionAndArgs->Action(ShortcutAction::NewTab); + auto newTabArgs = winrt::make_self(); + auto newTerminalArgs = winrt::make_self(); + newTerminalArgs->ProfileIndex(profileIndex); + newTabArgs->TerminalArgs(*newTerminalArgs); + actionAndArgs->Args(*newTabArgs); + auto profileKeyChord{ keyBindings.GetKeyBindingForActionWithArgs(*actionAndArgs) }; + + // make sure we find one to display + if (profileKeyChord) { - // Look for a keychord that is bound to the equivalent - // NewTab(ProfileIndex=N) action - auto actionAndArgs = winrt::make_self(); - actionAndArgs->Action(ShortcutAction::NewTab); - auto newTabArgs = winrt::make_self(); - auto newTerminalArgs = winrt::make_self(); - newTerminalArgs->ProfileIndex(profileIndex); - newTabArgs->TerminalArgs(*newTerminalArgs); - actionAndArgs->Args(*newTabArgs); - auto profileKeyChord{ keyBindings.GetKeyBindingForActionWithArgs(*actionAndArgs) }; - - // make sure we find one to display - if (profileKeyChord) - { - _SetAcceleratorForMenuItem(profileMenuItem, profileKeyChord); - } + _SetAcceleratorForMenuItem(profileMenuItem, profileKeyChord); } auto profileName = profile.GetName();