Skip to content

Commit ff3c40c

Browse files
authored
Merge pull request #8 from maiak/dev/chawill/user-prompt-docs
Update User Prompt Docs
2 parents 1fb9a65 + da941e2 commit ff3c40c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/extensibility/visualstudio.extensibility/user-prompt/user-prompts.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.technology: vs-ide-sdk
1212

1313
# Create Visual Studio user prompts
1414

15-
User prompts are a simple UI mechanism for prompting the user during the execution of a [Command](../command/command.md). Prompting the user creates a dialog box with a message, one to three buttons for the choices, and a dismiss button.
15+
User prompts are a simple UI mechanism for prompting the user to make a selection. Prompting the user creates a dialog box with a message, one to three buttons for the choices, and a dismiss button.
1616

1717
> [!NOTE]
1818
> The exact UI used to prompt users may change in future versions based on user feedback or other factors.
@@ -33,7 +33,7 @@ The choices presented to the user are mapped to return values of the type define
3333

3434
## Get started
3535

36-
User Prompts can only be created inside of a [Command](../command/command.md). To get started, [Create the extension project](../get-started/create-your-first-extension.md#create-the-extension-project) and [Add your first command](../get-started/create-your-first-extension.md#add-your-first-command).
36+
To get started, follow the [create the project](./../get-started/create-your-first-extension.md) section in the Getting Started section.
3737

3838
## Work with user prompts
3939

@@ -45,9 +45,9 @@ This guide covers the following scenarios for working with User Prompts:
4545

4646
## Display a user prompt
4747

48-
As discussed previously, user prompts can be shown inside of commands, where you have access to an `IClientContext` instance. To show a user prompt, call the `IClientContext.ShowPromptAsync<TResult>()` method inside the `ExecuteCommandAsync()` method for the command.
48+
Creating a user prompt with the new Extensibility Model is as simple as calling the `ShowPromptAsync` method from the [ShellExtensibility](/dotnet/api/microsoft.visualstudio.extensibility.shell.shellextensibility) helpers and passing in your options.
4949

50-
### `IClientContext.ShowPromptAsync<TResult>()`
50+
### `ShellExtensibility.ShowPromptAsync<TResult>()`
5151

5252
The `ShowPromptAsync()` method takes three parameters:
5353

@@ -64,7 +64,7 @@ The following code inside a `Command` shows a user prompt with a simple message
6464
```csharp
6565
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
6666
{
67-
await context.ShowPromptAsync("This is a user prompt.", PromptOptions.OK, cancellationToken))
67+
await this.Extensibility.Shell().ShowPromptAsync("This is a user prompt.", PromptOptions.OK, cancellationToken))
6868
}
6969
```
7070

@@ -105,7 +105,7 @@ Create a prompt with a single "OK" choice.
105105
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken ct)
106106
{
107107
// Asking the user to confirm an operation.
108-
if (!await context.ShowPromptAsync("Continue with executing the command?", PromptOptions.OKCancel, ct))
108+
if (!await this.Extensibility.Shell().ShowPromptAsync("Continue with executing the command?", PromptOptions.OKCancel, ct))
109109
{
110110
return;
111111
}
@@ -122,7 +122,7 @@ If the user clicks "OK", `ShowPromptAsync` returns `true` when awaited. If the u
122122
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken ct)
123123
{
124124
// Asking the user to confirm an operation.
125-
if (!await context.ShowPromptAsync("Continue with executing the command?", PromptOptions.OKCancel.WithCancelAsDefault(), ct))
125+
if (!await this.Extensibility.Shell().ShowPromptAsync("Continue with executing the command?", PromptOptions.OKCancel.WithCancelAsDefault(), ct))
126126
{
127127
return;
128128
}
@@ -159,7 +159,7 @@ Then create the `PromptOptions<TResult>` instance and pass it to `ShowPromptAsyn
159159
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken ct)
160160
{
161161
// Custom prompt
162-
var themeResult = await context.ShowPromptAsync(
162+
var themeResult = await this.Extensibility.Shell().ShowPromptAsync(
163163
"Which theme should be used for the generated output?",
164164
new PromptOptions<TokenThemeResult>
165165
{

0 commit comments

Comments
 (0)