-
Notifications
You must be signed in to change notification settings - Fork 676
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
Add Razor C# semantic tokens support in VS Code #6489
Add Razor C# semantic tokens support in VS Code #6489
Conversation
@@ -5175,6 +5175,168 @@ | |||
"markupCommentPunctuation": [ | |||
"punctuation.definition.comment.html", | |||
"comment.block.html" | |||
], | |||
"keyword": [ |
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.
This is needed to override the default colors VS Code uses since they can differ compared to what C# uses. For example, keyword
is colored purple by VS Code, but colored blue by C#.
Thanks @dibarbet for the tip!
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.
Interesting, so "keyword.cs" is already blue for VS Code and it just... knows?
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.
I'm guessing C# sets the color somewhere, although I'm not sure where. Maybe @dibarbet or @JoeRobich would know?
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.
I don't quite remember - it was potentially that the lsp token type for keyword
mapped to keyword.control
but keyword.cs
falls back to keyword
instead
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.
@@ -5369,7 +5531,10 @@ | |||
{ | |||
"language": "aspnetcorerazor", | |||
"scopeName": "text.aspnetcorerazor", | |||
"path": "./src/razor/syntaxes/aspnetcorerazor.tmLanguage.json" | |||
"path": "./src/razor/syntaxes/aspnetcorerazor.tmLanguage.json", | |||
"unbalancedBracketScopes": [ |
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.
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.
I'm not sure if this is the only one - you might want to test less than / greather than as well
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.
Ah you're right, and I was missing bit shifting operators as well. Thanks!
Co-authored-by: Andrew Hall <[email protected]>
…ens' into dev/allichou/AddRazorSemanticTokens
src/lsptoolshost/razorCommands.ts
Outdated
SerializableSemanticTokensParams, | ||
vscode.SemanticTokens, | ||
any | ||
>('roslyn/semanticTokenRanges'); |
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.
This is the new endpoint for when the feature flag is on, so we probably don't want to use it. We should be able to use the standard textDocument/semanticTokens/range
method.
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.
That's fair. It is kind of weird since we're still being sent an array of ranges from the server, so I had to hardcode in ranges[0]
to use the standard method.
Also, since we're going back to the standard method, I tested out the built-in vscode.provideDocumentRangeSemanticTokens
command and was actually able to get it working this time around. 😄 Definitely simplified the code
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.
Nice work!
Transitions C# in Razor to use semantic tokens instead of Textmate.
Fixes dotnet/razor#9336, dotnet/razor#4323, and dotnet/razor#4332
Examples of scenarios this fixes:
Before:
After:
Before:
After: