csharp-tmLanguage icon indicating copy to clipboard operation
csharp-tmLanguage copied to clipboard

Reserved keyword coloring?

Open winzig opened this issue 7 years ago • 2 comments

Would it be possible to get reserved word coloring on variables? It should match the color of the other reserved words, to make it more obvious that the variable name cannot be used.

Details

What editor are you seeing the problem in? VS Code

What version of the editor are you using? 1.22.2 and Insiders 1.23.0

What color theme are you using? Dark+ (default)

Repro

var event = new Dictionary<string, string>();

Ends up formatted like this, with no obvious sign that event is a reserved word:

screen shot 2018-04-17 at 12 07 50 pm

Instead of any reserved word errors, I kept seeing a bunch of (seemingly unrelated) errors in the vicinity of this line of code. I finally opened the project up in Visual Studio for macOS and it became obvious:

screen shot 2018-04-17 at 12 10 31 pm

winzig avatar Apr 17 '18 19:04 winzig

This is a good request. Unfortunately, since VS Code handles syntax highlighting purely with regular expressions, it's pretty hard to do. Essentially, every single rule would also need to include a rule that matches reserved words. If anyone wants to take a stab at it, we'll consider taking it. I'm afraid it might slow down the regular expressions in general though.

DustinCampbell avatar Apr 17 '18 19:04 DustinCampbell

Non-contextual keywords should just be detected in the same scope as this/base and built-in types (#260).

Could also argue that this is more about compiler error than syntax error, in which case the syntax highlighting should be more lenient and assume such syntax is valid.

wise0704 avatar Aug 08 '23 08:08 wise0704