mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Corrected the Run fallback handler to provide the same context items as it does on the run page.  **Closes:** #39092
39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
// 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 Microsoft.CmdPal.Ext.Shell.Commands;
|
|
using Microsoft.CmdPal.Ext.Shell.Helpers;
|
|
using Microsoft.CmdPal.Ext.Shell.Properties;
|
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
|
|
|
namespace Microsoft.CmdPal.Ext.Shell;
|
|
|
|
internal sealed partial class FallbackExecuteItem : FallbackCommandItem
|
|
{
|
|
private readonly ExecuteItem _executeItem;
|
|
private readonly SettingsManager _settings;
|
|
|
|
public FallbackExecuteItem(SettingsManager settings)
|
|
: base(new ExecuteItem(string.Empty, settings), Resources.shell_command_display_title)
|
|
{
|
|
_settings = settings;
|
|
_executeItem = (ExecuteItem)this.Command!;
|
|
Title = string.Empty;
|
|
_executeItem.Name = string.Empty;
|
|
Subtitle = Properties.Resources.generic_run_command;
|
|
Icon = Icons.RunV2; // Defined in Icons.cs and contains the execute command icon.
|
|
}
|
|
|
|
public override void UpdateQuery(string query)
|
|
{
|
|
_executeItem.Cmd = query;
|
|
_executeItem.Name = string.IsNullOrEmpty(query) ? string.Empty : Properties.Resources.generic_run_command;
|
|
Title = query;
|
|
MoreCommands = [
|
|
new CommandContextItem(new ExecuteItem(query, _settings, RunAsType.Administrator)),
|
|
new CommandContextItem(new ExecuteItem(query, _settings, RunAsType.OtherUser)),
|
|
];
|
|
}
|
|
}
|