EditorExtensibility.EditAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initiates an edit request in the host Visual Studio process, enabling the extension to atomically request one or more ITextDocumentSnapshot edits, caret position changes, or other state changes.
public System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.EditResponse> EditAsync (Action<Microsoft.VisualStudio.Extensibility.Editor.IEditBatch> editorSource, System.Threading.CancellationToken cancellationToken);
member this.EditAsync : Action<Microsoft.VisualStudio.Extensibility.Editor.IEditBatch> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.EditResponse>
Public Function EditAsync (editorSource As Action(Of IEditBatch), cancellationToken As CancellationToken) As Task(Of EditResponse)
Parameters
- editorSource
- Action<IEditBatch>
A service for obtaining editors for requesting changes to a IEditable<TEditor> object, such as ITextDocumentSnapshot.
- cancellationToken
- CancellationToken
Cancels a pending request.
Returns
A response object detailing whether the operation was successful and which ITextDocumentSnapshots and ITextViewSnapshots changed.
Remarks
Edit request is sent to Visual Studio IDE, where it succeeds only if the object being edited hasn't changed since the version the request was made one. If the document has changed, the change may be rejected, requiring the extension to retry on a newer version.
Edits are applied atomically. The best practice is to do all changes that should occur within a narrow time frame within a single EditAsync() call to reduce the likelihood of unexpected behavior arising from user edits, or language service actions that occur between edits.