From 0585bba9c59673c229edb82005c7fb0e45ca5077 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 14 Apr 2025 14:26:50 -0500 Subject: [PATCH 1/2] Update the settings form when ext settings are saved This one was subtle - the Settings class in the toolkit didn't ever change the items for a SettingsContentPage. For the main settings window, this was problematic. It would only ever hang onto one instance of that CommandSettings.SettingsContentPage, and never re-retrieve the value from it. This fixes that issue, by making sure to raise an ItemsChanged in the settings changed handler, so that we automatically pull down the new settings forms. For settings that were added to commands, as a context item, this wasn't an issue. They were always returning new forms to the host, with the current settings values in it. --- .../Microsoft.CommandPalette.Extensions.Toolkit/Settings.cs | 4 ++++ .../SettingsForm.cs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Settings.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Settings.cs index 39d3b1f85504..7f877664bd09 100644 --- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Settings.cs +++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Settings.cs @@ -118,6 +118,10 @@ public SettingsContentPage(Settings settings) _settings = settings; Name = "Settings"; Icon = new IconInfo("\uE713"); // Settings icon + + // When our settings change, make sure to let CmdPal know to + // retrieve the new forms + _settings.SettingsChanged += (s, e) => RaiseItemsChanged(); } } diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/SettingsForm.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/SettingsForm.cs index fa23cd8f0d32..79f548bf5605 100644 --- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/SettingsForm.cs +++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/SettingsForm.cs @@ -24,6 +24,12 @@ public override ICommandResult SubmitForm(string inputs, string data) return CommandResult.KeepOpen(); } + // Re-render the current value of the settings to a card. The + // SettingsContentPage will raise an ItemsChanged in its own + // SettingsChange handler, so we need to be prepared to return the + // current settings value. + TemplateJson = _settings.ToFormJson(); + _settings.Update(inputs); _settings.RaiseSettingsChanged(); From 7d9e5295d4b4a5a7138e63ea048e1cc9e15cc360 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 15 Apr 2025 06:27:17 -0500 Subject: [PATCH 2/2] straggler? --- .../Properties/Resources.Designer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Properties/Resources.Designer.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Properties/Resources.Designer.cs index c20800d1c1b8..ce7119976303 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Properties/Resources.Designer.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Properties/Resources.Designer.cs @@ -88,7 +88,7 @@ internal static string wox_plugin_service_name { } /// - /// Looks up a localized string similar to Open services (Ctrl+O). + /// Looks up a localized string similar to Open services. /// internal static string wox_plugin_service_open_services { get { @@ -133,7 +133,7 @@ internal static string wox_plugin_service_plugin_name { } /// - /// Looks up a localized string similar to Restart (Ctrl+R). + /// Looks up a localized string similar to Restart. /// internal static string wox_plugin_service_restart { get {