Skip to content

Commit

Permalink
- Fixed C#: Attribute Notation syntax highlighting inproperly depende…
Browse files Browse the repository at this point in the history
…ncy on Braces and Parentheses settings
  • Loading branch information
wmjordan committed May 18, 2023
1 parent 1c7e53a commit 32c09d6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Codist/Taggers/CSharpTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,17 @@ static TagSpan<IClassificationTag> ClassifyOperator(TextSpan itemSpan, ITextSnap
}

static TagSpan<IClassificationTag> ClassifyPunctuation(TextSpan itemSpan, ITextSnapshot snapshot, SemanticModel semanticModel, CompilationUnitSyntax unitCompilation, CancellationToken cancellationToken) {
if (HighlightOptions.AllBraces && itemSpan.Length == 1) {
if ((HighlightOptions.AllBraces || HighlightOptions.AttributeAnnotation) && itemSpan.Length == 1) {
switch (snapshot[itemSpan.Start]) {
case '(':
case ')':
return HighlightOptions.AllParentheses ? ClassifyParentheses(itemSpan, snapshot, semanticModel, unitCompilation, cancellationToken) : null;
case '{':
case '}':
return ClassifyCurlyBraces(itemSpan, snapshot, unitCompilation);
return HighlightOptions.AllBraces ? ClassifyCurlyBraces(itemSpan, snapshot, unitCompilation) : null;
case '[':
case ']':
return ClassifyBrackets(itemSpan, snapshot, semanticModel, unitCompilation, cancellationToken);
return HighlightOptions.AttributeAnnotation ? ClassifyBrackets(itemSpan, snapshot, semanticModel, unitCompilation, cancellationToken) : null;
}
}
return null;
Expand Down Expand Up @@ -839,7 +839,7 @@ static class HighlightOptions
public static TransientMemberTagHolder MemberBraceTags { get; private set; }

// use fields to cache option flags
public static bool AllBraces, AllParentheses, LocalFunctionDeclaration, NonPrivateField, StyleConstructorAsType, CapturingLambda;
public static bool AllBraces, AllParentheses, LocalFunctionDeclaration, NonPrivateField, StyleConstructorAsType, CapturingLambda, AttributeAnnotation;

static bool Init() {
Config.RegisterUpdateHandler(UpdateCSharpHighlighterConfig);
Expand Down Expand Up @@ -899,6 +899,7 @@ static void UpdateCSharpHighlighterConfig(ConfigUpdatedEventArgs e) {
LocalFunctionDeclaration = o.MatchFlags(SpecialHighlightOptions.LocalFunctionDeclaration);
NonPrivateField = o.MatchFlags(SpecialHighlightOptions.NonPrivateField);
StyleConstructorAsType = o.MatchFlags(SpecialHighlightOptions.UseTypeStyleOnConstructor);
AttributeAnnotation = FormatStore.GetStyles().TryGetValue(Constants.CSharpAttributeNotation, out var s) && s.IsSet;
}
}
}
Expand Down

0 comments on commit 32c09d6

Please sign in to comment.