From 21de7aa1eb9117a78d36e921165e31e0d7827293 Mon Sep 17 00:00:00 2001 From: MichelleTPY Date: Wed, 19 Aug 2020 10:28:31 +0100 Subject: [PATCH 1/2] Update profile shortcut based on profiles defined. --- src/cascadia/TerminalApp/TerminalPage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 7049dcf2841..835e8c2f576 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -462,8 +462,8 @@ 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 + if (profileIndex < profileCount) { // Look for a keychord that is bound to the equivalent // NewTab(ProfileIndex=N) action From bdf4af4d1b170069db2a95f7e44f2a2a106af173 Mon Sep 17 00:00:00 2001 From: MichelleTPY Date: Thu, 20 Aug 2020 22:20:25 +0100 Subject: [PATCH 2/2] Address code review comment: 1. Remove unnessary conditional check in loop. 2. Update indentation and code comments. --- 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 835e8c2f576..6de63a6be7b 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -462,25 +462,22 @@ namespace winrt::TerminalApp::implementation const auto& profile = _settings->GetProfiles()[profileIndex]; auto profileMenuItem = WUX::Controls::MenuFlyoutItem{}; - // add the keyboard shortcuts based on the number of profiles defined - if (profileIndex < profileCount) + // 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();