CmdPal: Display correct context items for run fallback (#39521)

Corrected the Run fallback handler to provide the same context items as
it does on the run page.


![image](https://github.com/user-attachments/assets/04a444b4-dc9f-4b63-8231-8f47f593b60f)

**Closes:** #39092
This commit is contained in:
Michael Jolley
2025-06-05 08:52:25 -05:00
committed by GitHub
parent dd2e7d17f9
commit 78b29c5b66

View File

@@ -12,10 +12,12 @@ namespace Microsoft.CmdPal.Ext.Shell;
internal sealed partial class FallbackExecuteItem : FallbackCommandItem internal sealed partial class FallbackExecuteItem : FallbackCommandItem
{ {
private readonly ExecuteItem _executeItem; private readonly ExecuteItem _executeItem;
private readonly SettingsManager _settings;
public FallbackExecuteItem(SettingsManager settings) public FallbackExecuteItem(SettingsManager settings)
: base(new ExecuteItem(string.Empty, settings), Resources.shell_command_display_title) : base(new ExecuteItem(string.Empty, settings), Resources.shell_command_display_title)
{ {
_settings = settings;
_executeItem = (ExecuteItem)this.Command!; _executeItem = (ExecuteItem)this.Command!;
Title = string.Empty; Title = string.Empty;
_executeItem.Name = string.Empty; _executeItem.Name = string.Empty;
@@ -28,5 +30,9 @@ internal sealed partial class FallbackExecuteItem : FallbackCommandItem
_executeItem.Cmd = query; _executeItem.Cmd = query;
_executeItem.Name = string.IsNullOrEmpty(query) ? string.Empty : Properties.Resources.generic_run_command; _executeItem.Name = string.IsNullOrEmpty(query) ? string.Empty : Properties.Resources.generic_run_command;
Title = query; Title = query;
MoreCommands = [
new CommandContextItem(new ExecuteItem(query, _settings, RunAsType.Administrator)),
new CommandContextItem(new ExecuteItem(query, _settings, RunAsType.OtherUser)),
];
} }
} }