-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cohosting OnAutoInsert endpoint #10674
Conversation
...src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
...src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/AutoClosingTagOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/InsertTextEdit.cs
Outdated
Show resolved
Hide resolved
...azor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AutoInsert/RemoteInsertTextEdit.cs
Outdated
Show resolved
Hide resolved
...soft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertEndpoint.cs
Outdated
Show resolved
Hide resolved
...soft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertEndpoint.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.LanguageServer/Hosting/VSInternalServerCapabilitiesExtensions.cs
Outdated
Show resolved
Hide resolved
...soft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertEndpoint.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.AspNetCore.Razor.LanguageServer/Hosting/VSInternalServerCapabilitiesExtensions.cs
Outdated
Show resolved
Hide resolved
061faae
to
51deccc
Compare
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
Outdated
Show resolved
Hide resolved
...soft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertEndpoint.cs
Show resolved
Hide resolved
1bebbf8
to
2587d1f
Compare
.../Microsoft.AspNetCore.Razor.LanguageServer/Hosting/VSInternalServerCapabilitiesExtensions.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/OOPAutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/AutoInsert/RemoteAutoInsertService.cs
Outdated
Show resolved
Hide resolved
cancellationToken | ||
); | ||
return autoInsertResponseItem is not null | ||
? Response.Results(RemoteInsertTextEdit.FromRoslynAutoInsertResponse(autoInsertResponseItem)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there some mapping that needs to happen, to get the LinePositionSpan
contained in this response back to Razor coordinates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes unfortunately. It's done in the original endpoint by the RazorFormattingService. I didn't realize that besides doing code formatting it also remaps document positions from C# to Razor (during CSharpOnTypeFormattingPass from what I can tell).
Does it mean that we need to move RazorFormattingService to the common layer after all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yeah, I forgot that on type formatting (which this would use internally) works on being given a set of C# edits. Yes, this will need the formatting service to move down.
...soft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostOnAutoInsertEndpoint.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IAutoInsertService.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/AutoInsert/IOnAutoInsertProvider.cs
Outdated
Show resolved
Hide resolved
|
||
var codeDocument = await remoteDocumentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
var languageKind = _documentMappingService.GetLanguageKind(codeDocument, index, rightAssociative: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happened to be looking at the existing AutoInsert endpoint today, for other reasons, and noticed is uses this: https://github.com/dotnet/razor/blob/main/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/PreferHtmlInAttributeValuesDocumentPositionStrategy.cs#L19
We'll need to do that here too, to get matching behaviour. Should be able to just move it down to Workspaces, and call the static Instance property etc.
98a1ba2
to
6089d38
Compare
…rt/AutoClosingTagOnAutoInsertProvider.cs Co-authored-by: David Wengier <[email protected]>
…rt/IAutoInsertService.cs Co-authored-by: David Wengier <[email protected]>
…rt/InsertTextEdit.cs Co-authored-by: David Wengier <[email protected]>
- IDocumentMappingService was not needed (and not available via MEF), so removed that - TextDocument does not implmement VSInternalTextDocumentClientCapabilities
… of places per CR suggestion
…fer our own AutoInsertService first)
dc85b28
to
53e5186
Compare
Moving GetFormatterCodeDocumentAsync() into IDocumentSnapshot (and implementations of that) to allow eaiser differentiation of behavior in remote (cohosting) case where we don't need to check the flag on Project.Configuration. Also AddUsingStatementsIfNeeded *always* gets called, even in cases when they are not actually needed, so we can't Debug.Fail there.
…the original code does That allows the code insert double-quotes by delegating to HTML language server after attribute name and equals.
Summary of the changes
Fixes:
Part of #9519
Notes:
All auto-insert scenarios should be addressed now (Razor, HTML, C#)
Tests will be added in a separate PR since this one has grown large and long enough as it is.