[LSP] Fix semantic tokens overlap bug#58620
Merged
allisonchou merged 3 commits intodotnet:release/dev17.1from Jan 6, 2022
Merged
[LSP] Fix semantic tokens overlap bug#58620allisonchou merged 3 commits intodotnet:release/dev17.1from
allisonchou merged 3 commits intodotnet:release/dev17.1from
Conversation
Contributor
Author
|
@jinujoseph for M2 approval |
ryzngard
approved these changes
Jan 5, 2022
| classifiedSpans.AddRange(spans); | ||
|
|
||
| // The spans returned to us may include some empty spans, which we don't care about. | ||
| var nonEmptySpans = spans.Where(s => !s.TextSpan.IsEmpty); |
Contributor
There was a problem hiding this comment.
What is the use case for empty spans that are classified?
Contributor
Author
There was a problem hiding this comment.
I can't seem to reproduce it anymore, but there was a file where somehow an empty span was being produced as part of a classification. Razor breaks with empty spans (via a failed assert), so I thought it'd be good to just include this here as a precaution. Empty spans are also unnecessary to return in the LSP case.
Contributor
Author
There was a problem hiding this comment.
This actually seems to be a bug in AdjustSpans - for now I filed #58658 to track, but it shouldn't block this PR.
src/Workspaces/Core/Portable/Classification/ClassifierHelper.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Classification/ClassifierHelper.cs
Outdated
Show resolved
Hide resolved
dibarbet
approved these changes
Jan 5, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I inadvertently introduced a bug in #58238, in which we sometimes return both semantic and syntactic classifications for the same TextSpan. In reality, if there is a semantic classification, it should override the syntactic classification for any matching TextSpan unless the syntactic classification is a modifier (e.g.
static).This bug introduced was caught via an assert failure in Razor and is currently breaking semantic tokens on their end.
The existing LSP semantic tokens tests were previously partially incorrect. They have been updated this PR and now have the correct expected results, which should help catch this problem in the future.