public override Task <object?> HandleRequestAsync(LSP.DidChangeTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) { var text = context.GetTrackedDocumentSourceText(request.TextDocument.Uri); // Per the LSP spec, each text change builds upon the previous, so we don't need to translate // any text positions between changes, which makes this quite easy. var changes = request.ContentChanges.Select(change => ProtocolConversions.ContentChangeEventToTextChange(change, text)); text = text.WithChanges(changes); context.UpdateTrackedDocument(request.TextDocument.Uri, text); return(SpecializedTasks.Default <object>()); }
public override async Task <object> HandleRequestAsync(LSP.DidChangeTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) { Contract.ThrowIfNull(context.Document); var text = await context.Document.GetTextAsync(cancellationToken).ConfigureAwait(false); // Per the LSP spec, each text change builds upon the previous, so we don't need to translate // any text positions between changes, which makes this quite easy. var changes = request.ContentChanges.Select(change => ProtocolConversions.ContentChangeEventToTextChange(change, text)); text = text.WithChanges(changes); context.UpdateTrackedDocument(request.TextDocument.Uri, text); return(true); }