From 813f385c08ae3b10ae782d3b0116ba352ca6fda5 Mon Sep 17 00:00:00 2001 From: kovdu Date: Tue, 15 Jun 2021 01:32:31 +0200 Subject: [PATCH] Don't dispatch the Toggle Command Palette action to keep the just closed Command Palette closed. (#10423) An exception was introduced for the 'Toggle Command Palette' action to **not** being dispatched. Otherwise the command palette that was just closed will become visible again. ## PR Checklist * [x] Closes #10240 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA ## Detailed Description of the Pull Request / Additional comments - Selecting the `Toggle command palette` item in the command palette will now properly close the command palette. - Opening and closing the Command Palette through shortcut keys is still working fine. - Other command palette items are still working fine as well. --- src/cascadia/TerminalApp/CommandPalette.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalApp/CommandPalette.cpp b/src/cascadia/TerminalApp/CommandPalette.cpp index 5ed45317e..651158122 100644 --- a/src/cascadia/TerminalApp/CommandPalette.cpp +++ b/src/cascadia/TerminalApp/CommandPalette.cpp @@ -644,7 +644,13 @@ namespace winrt::TerminalApp::implementation // palette like the Tab Switcher will be able to have the last laugh. _close(); - _DispatchCommandRequestedHandlers(*this, actionPaletteItem.Command()); + // But make an exception for the Toggle Command Palette action: we don't want the dispatch + // make the command palette - that was just closed - visible again. + // All other actions can just be dispatched. + if (actionPaletteItem.Command().ActionAndArgs().Action() != ShortcutAction::ToggleCommandPalette) + { + _DispatchCommandRequestedHandlers(*this, actionPaletteItem.Command()); + } TraceLoggingWrite( g_hTerminalAppProvider, // handle to TerminalApp tracelogging provider