Skip to content

Commit 98f8397

Browse files
committed
add how to debug information
1 parent a244858 commit 98f8397

1 file changed

Lines changed: 63 additions & 2 deletions

File tree

hub/powertoys/command-palette/adding-commands.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,70 @@ public override IListItem[] GetItems()
4949
}
5050
```
5151

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:
5353

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+
![Screenshot of reload](../../images/command-palette/reload.png)
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+
![Screenshot of reload](../../images/command-palette/debug-configuration.png)
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+
![Screenshot of reload](../../images/command-palette/output.png)
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**.
55116

56117
```csharp
57118
using System.Runtime.InteropServices;

0 commit comments

Comments
 (0)