Open Sergio0694 opened 2 years ago
Weird. not repro-ing for me:
Just tried and couldn't repro as well.
Mmmh I wonder if this might be the JetBrains Mono font, as I can see it's using a ligature there? 🤔 Though why should a custom font possibly mess with the syntax highlight colors?
cc @olegtk for info
@gundermanc, @veler, this is interesting, do ligatures affect classification?
Not AFAIK
@veler We're specifically interested in the case where a ligature is formed from two characters which independently have two different classifications. For this case, either the ligature needs to be avoided or the ligature characters needs to be rendered with multiple colors.
Ideally it would be great if the ligature could just be skipped entirely here, as having #{
be merged makes no sense in C# anyway (or at least, here specifically) 🤔
@CyrusNajmabadi @Youssef1313 Just managed to find another repro for this, happens with vanilla VS 17.4.3:
class Repro
{
private static int _number;
public void Problem()
{
Console.WriteLine($"Hello #{_number}");
}
}
Results in:
I think the font you are using is different than mine. So it may be related to the font being used.
Yeah, I have more info. I can't repro with Consolas and Cascadia Mono. With Cascadia Code I get the same result as you (both # and { are orange). In my screenshot, I'm using JetBrains Mono. So it does seem the specific font affects the syntax highlight 🤔
I'm not sure, but this might not be a roslyn issue. More likely in VS editor (internal).
Yeah uh, something is very wrong if Roslyn even has a concept of font families in the first place.
This just looks like VS failing to break ligatures if the characters have mismatching colors, and thus rendering incorrectly.
@olegtk to decide if you guys want to do anything here. Def not a Roslyn issue.
yeah, it's a bug in the VS editor. @Sergio0694, would you mind reporting this via Help > Send Feedback > Report a Problem ? This way we will get publicly visible feedback ticket others can also vote on and comment. We would like to see more votes before we invest into fixing this, unfortunately it looks pretty complicated as we don't have much control over ligature rendering in WPF.
Version Used: VS2022 17.0.2
Steps to Reproduce:
Expected Behavior:
The
#
character should be colored in orange like other normal characters in the interpolated expression.Actual Behavior:
The
#
character is colored in gray, like a preprocessor directive:Builds and works just fine at runtime, it's just a visual glitch in the syntax highlight.