Adding fallback command for Windows Settings extension (#40331)

Two changes:

- Added a new fallback command for Windows Settings extension. If only
one setting or one exact match for the query was found, display that
setting in the list and open that setting on <Enter>. If more than one
setting was found, display a message to open Windows Settings to see the
search results for your query.


![image](https://github.com/user-attachments/assets/bd5708a5-b1d5-466e-9c62-cd1cd7bb1f74)


![image](https://github.com/user-attachments/assets/98f4ac20-efe1-4782-8133-30afa17e3b7d)


![image](https://github.com/user-attachments/assets/e5da90e1-f89b-480c-bd26-214c68ac013a)

- Modified the titles/subtitles of the extension to pull from Resources
to aid in internationalization.

Closes: #38548 and possibly #40308
This commit is contained in:
Michael Jolley
2025-07-08 10:05:02 -05:00
committed by GitHub
parent c6cee94456
commit f34735edeb
7 changed files with 245 additions and 77 deletions

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using Microsoft.CmdPal.Ext.WindowsSettings.Helpers;
using Microsoft.CmdPal.Ext.WindowsSettings.Pages;
using Microsoft.CmdPal.Ext.WindowsSettings.Properties;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -17,6 +18,8 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
private readonly WindowsSettings.Classes.WindowsSettings? _windowsSettings;
#pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
private readonly FallbackWindowsSettingsItem _fallback;
public WindowsSettingsCommandsProvider()
{
Id = "Windows.Settings";
@@ -26,9 +29,10 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
_windowsSettings = JsonSettingsListHelper.ReadAllPossibleSettings();
_searchSettingsListItem = new CommandItem(new WindowsSettingsListPage(_windowsSettings))
{
Title = "Windows Settings",
Subtitle = "Navigate to specific Windows settings",
Title = Resources.settings_title,
Subtitle = Resources.settings_subtitle,
};
_fallback = new(_windowsSettings);
UnsupportedSettingsHelper.FilterByBuild(_windowsSettings);
@@ -42,4 +46,6 @@ public partial class WindowsSettingsCommandsProvider : CommandProvider
_searchSettingsListItem
];
}
public override IFallbackCommandItem[] FallbackCommands() => [_fallback];
}