From 98421fada34c2b42f5f183afad9aaf071ff13954 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Mon, 9 Sep 2024 16:42:50 +1000 Subject: [PATCH] Fix auto insert service after merge from main --- .../AutoInsert/RemoteAutoInsertService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs index 557a11528a..119d984e73 100644 --- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs @@ -154,8 +154,8 @@ internal sealed class RemoteAutoInsertService(in ServiceArgs args) var razorFormattingOptions = options.FormattingOptions; - var sourceText = await remoteDocumentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false); - var csharpTextChange = new TextChange(sourceText.GetTextSpan(autoInsertResponseItem.TextEdit.Range), autoInsertResponseItem.TextEdit.NewText); + var csharpSourceText = await remoteDocumentContext.GetCSharpSourceTextAsync(cancellationToken).ConfigureAwait(false); + var csharpTextChange = new TextChange(csharpSourceText.GetTextSpan(autoInsertResponseItem.TextEdit.Range), autoInsertResponseItem.TextEdit.NewText); var mappedChange = autoInsertResponseItem.TextEditFormat == RoslynInsertTextFormat.Snippet ? await _razorFormattingService.TryGetCSharpSnippetFormattingEditAsync( remoteDocumentContext, @@ -175,6 +175,7 @@ internal sealed class RemoteAutoInsertService(in ServiceArgs args) return Response.NoFurtherHandling; } + var sourceText = await remoteDocumentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false); return Response.Results( new RemoteAutoInsertTextEdit( sourceText.GetLinePositionSpan(change.Span),