/ src / modules / cmdpal / Microsoft.CmdPal.UI.ViewModels / Commands / ReloadExtensionsCommand.cs
ReloadExtensionsCommand.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using CommunityToolkit.Mvvm.Messaging;
 6  using Microsoft.CmdPal.Core.ViewModels.Messages;
 7  using Microsoft.CmdPal.UI.ViewModels.Messages;
 8  using Microsoft.CommandPalette.Extensions;
 9  using Microsoft.CommandPalette.Extensions.Toolkit;
10  
11  namespace Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;
12  
13  public partial class ReloadExtensionsCommand : InvokableCommand
14  {
15      public ReloadExtensionsCommand()
16      {
17          Icon = new IconInfo("\uE72C"); // Refresh icon
18      }
19  
20      public override ICommandResult Invoke()
21      {
22          // 1% BODGY: clear the search before reloading, so that we tell in-proc
23          // fallback handlers the empty search text
24          WeakReferenceMessenger.Default.Send<ClearSearchMessage>();
25          WeakReferenceMessenger.Default.Send<ReloadCommandsMessage>();
26          return CommandResult.GoHome();
27      }
28  }