-
Notifications
You must be signed in to change notification settings - Fork 199
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,10 @@ public RazorSemanticTokensInfoService( | |
{ | ||
csharpSemanticRanges = await GetCSharpSemanticRangesAsync(codeDocument, textDocumentIdentifier, range, razorSemanticTokensLegend, documentContext.Version, correlationId, cancellationToken).ConfigureAwait(false); | ||
} | ||
catch (OperationCanceledException) | ||
{ | ||
return null; | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, "Error thrown while retrieving CSharp semantic range."); | ||
|
@@ -230,7 +234,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')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is subtle, nice catch! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 🤦🏼♂️ |
||
{ | ||
return false; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
using Microsoft.AspNetCore.Razor.LanguageServer.Semantic; | ||
using Microsoft.AspNetCore.Razor.LanguageServer.Semantic.Models; | ||
using Microsoft.AspNetCore.Razor.PooledObjects; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage; | ||
using Microsoft.VisualStudio.LanguageServer.Protocol; | ||
using StreamJsonRpc; | ||
|
@@ -85,10 +86,12 @@ internal partial class RazorCustomMessageTarget | |
var nonEmptyResults = results.Select(r => r?.Response?.Data).WithoutNull().ToArray(); | ||
if (nonEmptyResults.Length != semanticTokensParams.Ranges.Length) | ||
{ | ||
_logger?.LogDebug("Made {count} semantic tokens requests to Roslyn but only got {nonEmpty} results back", semanticTokensParams.Ranges.Length, nonEmptyResults.Length); | ||
// 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
return new ProvideSemanticTokensResponse(nonEmptyResults, semanticTokensParams.RequiredHostDocumentVersion); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//line,characterPos,length,tokenType,modifier,text | ||
0 0 1 razorTransition 0 [@] | ||
0 1 5 keyword 4 [using] | ||
0 5 1 markupTextLiteral 4 [ ] | ||
0 1 6 namespace name 4 [System] | ||
1 0 1 razorTransition 0 [@] | ||
0 1 4 razorDirective 0 [code] | ||
1 0 1 razorTransition 0 [{] | ||
1 0 1 markupTextLiteral 4 [ ] | ||
0 1 7 keyword 4 [private] | ||
0 7 1 markupTextLiteral 4 [ ] | ||
0 1 6 keyword 4 [static] | ||
0 6 1 markupTextLiteral 4 [ ] | ||
0 1 4 keyword 4 [bool] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 9 field name 5 [_isStatic] | ||
0 9 1 punctuation 4 [;] | ||
2 0 1 markupTextLiteral 4 [ ] | ||
0 1 6 keyword 4 [public] | ||
0 6 1 markupTextLiteral 4 [ ] | ||
0 1 4 keyword 4 [void] | ||
0 4 1 markupTextLiteral 4 [ ] | ||
0 1 1 method name 4 [M] | ||
0 1 1 punctuation 4 [(] | ||
0 1 1 punctuation 4 [)] | ||
1 0 1 markupTextLiteral 4 [ ] | ||
0 1 1 punctuation 4 [{] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 2 keyword - control 4 [if] | ||
0 2 1 markupTextLiteral 4 [ ] | ||
0 1 1 punctuation 4 [(] | ||
0 1 9 field name 5 [_isStatic] | ||
0 9 1 punctuation 4 [)] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 1 punctuation 4 [{] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 1 punctuation 4 [}] | ||
1 0 1 markupTextLiteral 4 [ ] | ||
0 1 1 punctuation 4 [}] | ||
1 0 1 razorTransition 0 [}] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//line,characterPos,length,tokenType,modifier,text | ||
0 0 1 razorTransition 0 [@] | ||
0 1 5 keyword 4 [using] | ||
0 5 1 markupTextLiteral 4 [ ] | ||
0 1 6 namespace name 4 [System] | ||
1 0 1 razorTransition 0 [@] | ||
0 1 4 razorDirective 0 [code] | ||
1 0 1 razorTransition 0 [{] | ||
1 0 1 markupTextLiteral 4 [ ] | ||
0 1 7 keyword 4 [private] | ||
0 7 1 markupTextLiteral 4 [ ] | ||
0 1 6 keyword 4 [static] | ||
0 6 1 markupTextLiteral 4 [ ] | ||
0 1 4 keyword 4 [bool] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 9 field name 5 [_isStatic] | ||
0 9 1 punctuation 4 [;] | ||
2 0 1 markupTextLiteral 4 [ ] | ||
0 1 6 keyword 4 [public] | ||
0 6 1 markupTextLiteral 4 [ ] | ||
0 1 4 keyword 4 [void] | ||
0 4 1 markupTextLiteral 4 [ ] | ||
0 1 1 method name 4 [M] | ||
0 1 1 punctuation 4 [(] | ||
0 1 1 punctuation 4 [)] | ||
1 0 1 markupTextLiteral 4 [ ] | ||
0 1 1 punctuation 4 [{] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 2 keyword - control 4 [if] | ||
0 2 1 markupTextLiteral 4 [ ] | ||
0 1 1 punctuation 4 [(] | ||
0 1 9 field name 5 [_isStatic] | ||
0 9 1 punctuation 4 [)] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 1 punctuation 4 [{] | ||
1 0 2 markupTextLiteral 4 [ ] | ||
0 2 1 punctuation 4 [}] | ||
1 0 1 markupTextLiteral 4 [ ] | ||
0 1 1 punctuation 4 [}] | ||
1 0 1 razorTransition 0 [}] |
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.
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!