Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.IO;
using Microsoft.CommandPalette.Extensions.Toolkit;

namespace TemplateCmdPalExtension;

internal sealed partial class SettingsManager : JsonSettingsManager
{
private static readonly string _namespace = "templatecmdpalextension";

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

templatecmdpalextension is not a recognized word. (unrecognized-spelling)

private static string Namespaced(string propertyName) => $"{_namespace}.{propertyName}";
Comment on lines +12 to +14
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _namespace value is hard-coded to "templatecmdpalextension" and (unlike "TemplateCmdPalExtension" elsewhere) it likely won’t be updated by the template substitution. That means generated extensions will keep the same settings key prefix unless the developer notices and edits it, which can lead to confusing/duplicated setting IDs (especially if settings are ever stored in a shared JSON). Consider deriving this prefix from the project/assembly name (or using the same token/casing as the other template-replaced strings) so it stays consistent automatically.

Copilot uses AI. Check for mistakes.

// TODO: Add your settings here. For example:
// private readonly ToggleSetting _myToggle = new(
// Namespaced(nameof(MyToggle)),
// "My toggle setting",
// "Description of my toggle setting",
// false);

// TODO: Add accessors for each setting. For example:
// public bool MyToggle => _myToggle.Value;

internal static string SettingsJsonPath()
{
var directory = Utilities.BaseSettingsPath("TemplateCmdPalExtension");
Directory.CreateDirectory(directory);

return Path.Combine(directory, "settings.json");
}

public SettingsManager()
{
FilePath = SettingsJsonPath();

// TODO: Register your settings here. For example:
// Settings.Add(_myToggle);

// Load settings from file upon initialization
LoadSettings();

Settings.SettingsChanged += (_, _) => SaveSettings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ namespace TemplateCmdPalExtension;
public partial class TemplateCmdPalExtensionCommandsProvider : CommandProvider
{
private readonly ICommandItem[] _commands;
private readonly SettingsManager _settingsManager = new();

public TemplateCmdPalExtensionCommandsProvider()
{
DisplayName = "TemplateDisplayName";
Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.png");
_commands = [
new CommandItem(new TemplateCmdPalExtensionPage()) { Title = DisplayName },
new CommandItem(new TemplateCmdPalExtensionPage())
{
Title = DisplayName,
MoreCommands = [new CommandContextItem(_settingsManager.Settings.SettingsPage)],
},
];

Settings = _settingsManager.Settings;
}

public override ICommandItem[] TopLevelCommands()
{
return _commands;
}

}
Loading