Skip to content
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

Fix C# background color bug when using tab indentation #9257

Merged
merged 3 commits into from
Sep 9, 2023

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Sep 8, 2023

Noticed while testing with a customer solution.

Commit-at-a-time to make the difference in the test baseline visible with the bug fix.

@davidwengier davidwengier requested a review from a team as a code owner September 8, 2023 04:51
@@ -70,6 +70,10 @@ internal class RazorSemanticTokensInfoService : IRazorSemanticTokensInfoService
{
csharpSemanticRanges = await GetCSharpSemanticRangesAsync(codeDocument, textDocumentIdentifier, range, razorSemanticTokensLegend, documentContext.Version, correlationId, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed in the logs we were reporting this as an issue, when its totally normal, and in fact it should probably happen a little more than it does now!

// Weren't able to re-invoke C# semantic tokens but we have to indicate it's due to out of sync by providing the old version
return new ProvideSemanticTokensResponse(tokens: null, hostDocumentSyncVersion: csharpDoc.HostDocumentSyncVersion ?? -1);
}

_logger?.LogDebug("Made {count} semantic tokens requests to Roslyn", semanticTokensParams.Ranges.Length);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snuck this one in too, so we can see what is going on with our new feature flag.

@@ -230,7 +230,7 @@ private static bool ContainsOnlySpacesOrTabs(SourceText razorSource, int startIn
var end = startIndex + count;
for (var i = startIndex; i < end; i++)
{
if (razorSource[i] is not ' ' or '\t')
if (razorSource[i] is not (' ' or '\t'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is subtle, nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been nicer to catch it when I wrote the code in the first place. Not the first time I've made this mistake either 🤦🏼‍♂️

@davidwengier davidwengier merged commit 927d878 into dotnet:main Sep 9, 2023
@davidwengier davidwengier deleted the SemanticTokens branch September 9, 2023 01:02
@ghost ghost added this to the Next milestone Sep 9, 2023
@Cosifne Cosifne modified the milestones: Next, 17.8 P3 Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants