From 92167a554aef25cc64315cd73e2f71edfc02d8bf Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 9 Jul 2020 11:16:09 -0500 Subject: [PATCH] code cleanup --- src/cascadia/TerminalApp/CommandPalette.cpp | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/cascadia/TerminalApp/CommandPalette.cpp b/src/cascadia/TerminalApp/CommandPalette.cpp index 7923f650e0..246fab4695 100644 --- a/src/cascadia/TerminalApp/CommandPalette.cpp +++ b/src/cascadia/TerminalApp/CommandPalette.cpp @@ -174,6 +174,15 @@ namespace winrt::TerminalApp::implementation _dispatchCommand(e.ClickedItem().try_as()); } + // Method Description: + // - This is called when the user selects a command with subcommands. It + // will update our UI to now display the list of subcommands instead, and + // clear the search text so the user can search from the new list of + // commands. + // Arguments: + // - + // Return Value: + // - void CommandPalette::_updateUIForStackChange() { if (_searchBox().Text().empty()) @@ -183,9 +192,19 @@ namespace winrt::TerminalApp::implementation _filterTextChanged(nullptr, nullptr); } + // Changing the value of the search box will trigger _filterTextChanged, + // which will cause us to refresh the list of filterable commands. _searchBox().Text(L""); } + // Method Description: + // - Retrieve the list of commands that we should currently be filtering. + // * If the user has command with subcommands, this will return that command's subcommands. + // * Otherwise, just return the list of all the top-level commands. + // Arguments: + // - + // Return Value: + // - A list of Commands to filter. Collections::IVector CommandPalette::_commandsToFilter() { if (_nestedActionStack.Size() > 0) @@ -211,6 +230,9 @@ namespace winrt::TerminalApp::implementation { if (command.NestedCommands().Size() > 0) { + // If this Command had subcommands, then don't dispatch the + // action. Instead, display a new list of commands for the user + // to pick from. _nestedActionStack.Append(command); _updateUIForStackChange(); }