You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/powertoys/command-palette/adding-commands.md
+63-2Lines changed: 63 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,9 +49,70 @@ public override IListItem[] GetItems()
49
49
}
50
50
```
51
51
52
-
Re-deploy your app, run the "reload" command to refresh the extensions in the palette, and head to your extension. You should see that the command now opens the Command Palette documentation.
52
+
To update the extension in the Command Palette you need to:
53
53
54
-
The **OpenUrlCommand** is a helper for opening a URL in the user's default web browser. You can also implement an extension however you want. Let's instead make a new command, that shows a **MessageBox**. To do that, we need to create a new class that implements **IInvokableCommand**.
54
+
1. Deploy your app
55
+
1. In the Command Palette, type the "reload" command to refresh the extensions in the palette
56
+
57
+

58
+
59
+
> [!NOTE]
60
+
> There are several reload options, make sure to select the **Reload Command Palette extensions**
61
+
62
+
1. Scroll down to your extension and press `enter`
63
+
1. Press `enter` on `Open the Command Palette documentation`
64
+
1. You should see that the command now opens the Command Palette documentation
65
+
66
+
The **OpenUrlCommand** is a helper for opening a URL in the user's default web browser.
67
+
68
+
## Debugging Extension
69
+
70
+
As your building your extension, you'll most likely want to debug it.
71
+
72
+
1. Add a debug message to the `GetItems` function.
73
+
74
+
```diff
75
+
public override IListItem[] GetItems()
76
+
{
77
+
var command = new OpenUrlCommand("https://learn.microsoft.com/windows/powertoys/command-palette/adding-commands");
78
+
79
+
+ Debug.Write("Debug message from GetItems");
80
+
81
+
return [
82
+
new ListItem(command)
83
+
{
84
+
Title = "Open the Command Palette documentation",
85
+
}
86
+
];
87
+
}
88
+
```
89
+
90
+
1. Deploy your app, wait until it's successful
91
+
1. Confirm You're in Debug Configuration
92
+
93
+
<details>
94
+
<summary>Instructions to confirm debug configuration</summary>
95
+
96
+
1. Look at the toolbar at the top of Visual Studio
97
+
1. You’ll see a dropdown that says either `Debug` or `Release` (next to the green "Start" button ▶️)
98
+
1. If it says `Release`, click the dropdown and select `Debug`.
99
+
100
+

101
+
102
+
</details>
103
+
104
+
1. Run the app in debug by pressing the green "Start" button ▶️ or press `F5`
105
+
1. Ensure the Output window is set to show `Debug` output (Ctrl + Alt + O)
106
+
107
+

108
+
109
+
1. In the Command Palette, `reload`
110
+
1. Go to your extension and select `Open the Command Palette documentation`.
111
+
1. In Visual Studio's output window, you should see `Debug message from GetItems`
112
+
113
+
## InvokableCommand Command
114
+
115
+
You can also implement an extension however you want. Let's instead make a new command, that shows a **MessageBox**. To do that, we need to create a new class that implements **IInvokableCommand**.
0 commit comments