Update the settings form when ext settings are saved (#38851)

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.

Closes #38191
This commit is contained in:
Mike Griese
2025-04-16 14:50:56 -05:00
committed by GitHub
parent 67463abf98
commit 01584f33e1
2 changed files with 10 additions and 0 deletions

View File

@@ -118,6 +118,10 @@ public sealed partial class Settings : ICommandSettings
_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();
}
}

View File

@@ -24,6 +24,12 @@ public partial class SettingsForm : FormContent
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();