Skip to content

Commit 1fb9a65

Browse files
authored
Merge pull request #7 from maiak/dev/bertaygu/getstarted
Updates to getting started docs
2 parents 84d7399 + a1e799c commit 1fb9a65

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

docs/extensibility/visualstudio.extensibility/get-started/tutorial-create-simple-extension.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ public override async Task ExecuteCommandAsync(IClientContext context, Cancellat
9393
return;
9494
}
9595

96-
var document = await textView.GetTextDocumentAsync(cancellationToken);
9796
await this.Extensibility.Editor().EditAsync(
9897
batch =>
9998
{
100-
document.AsEditable(batch).Replace(textView.Selection.Extent, newGuidString);
99+
textView.Document.AsEditable(batch).Replace(textView.Selection.Extent, newGuidString);
101100
},
102101
cancellationToken);
103102
}
@@ -107,8 +106,6 @@ The first line validates the arguments, then we create a new `Guid` to use later
107106

108107
Then, we create an `ITextViewSnapshot` (the `textView` object here) by calling the asynchronous method `GetActiveTextViewAsync`. A cancellation token is passed in to preserve the ability to cancel the asynchronous request, but this isn't demonstrated in this sample. If we don't get a text view successfully, we'll write to the log and terminate without doing anything else.
109108

110-
Next, we request the document, an instance of `ITextDocumentSnapshot` (here `document`).
111-
112109
Now we're ready to call the asynchronous method that submits an edit request to Visual Studio's editor. The method we want is `EditAsync`. That's a member of the `EditorExtensibility` class, which allows interaction with the running Visual Studio Editor in the IDE. The `Command` type, which your own `InsertGuidCommand` class inherits from, has a member `Extensibility` that provides access to the `EditorExtensibility` object, so we can get to the `EditorExtensibility` class with a call to `this.Extensibility.Editor()`.
113110

114111
The `EditAsync` method takes an `Action<IEditBatch>` as a parameter. This is called `editorSource`,
@@ -119,7 +116,7 @@ The call to `EditAsync` uses a lambda expression. To break this down a little, y
119116
await this.Extensibility.Editor().EditAsync(
120117
batch =>
121118
{
122-
var editor = document.AsEditable(batch);
119+
var editor = textView.Document.AsEditable(batch);
123120
// specify the desired changes here:
124121
editor.Replace(textView.Selection.Extent, newGuidString);
125122
},

0 commit comments

Comments
 (0)