Compartilhar via


DocumentsExtensibility.GetTextDocumentSnapshotAsync Method

Definition

Gets a ITextDocumentSnapshot from an open document snapshot.

public System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.ITextDocumentSnapshot?> GetTextDocumentSnapshotAsync (Microsoft.VisualStudio.RpcContracts.Documents.DocumentSnapshot documentSnapshot, System.Threading.CancellationToken cancellationToken);
member this.GetTextDocumentSnapshotAsync : Microsoft.VisualStudio.RpcContracts.Documents.DocumentSnapshot * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.ITextDocumentSnapshot>
Public Function GetTextDocumentSnapshotAsync (documentSnapshot As DocumentSnapshot, cancellationToken As CancellationToken) As Task(Of ITextDocumentSnapshot)

Parameters

documentSnapshot
DocumentSnapshot

The document to operate on.

cancellationToken
CancellationToken

The cancellation token.

Returns

A text document snapshot matching the version of the document snapshot.

Exceptions

Thrown when snapshot version is no longer available.

Remarks

This method will either: - Get a text document that matches the version of the snapshot. - For document snapshots that were not initialized yet, it will force initialize the document and get the initial version. - For documents without a version, it will return null as they are not supported. - For document snapshots that are no longer open in IDE, it will return null. - Will throw SnapshotVersionNotAvailableException if document is old and is not available anymore, in this case another call to InitializeDocumentAsync(DocumentSnapshot, CancellationToken) should return a newer version.

Applies to