better-cpp-syntax
better-cpp-syntax copied to clipboard
Shouldn't c++ preprocessor #elif's textmate scope be keyword.control.directive.conditional.elif?
From @REYNEP in https://github.com/microsoft/vscode/issues/114297
Checklist
- [ ] This problem exists even with the setting
"C_Cpp.enhancedColorization": "Disabled" - [ ] This bug exists for C
- [x] This bug exists for C++
- [ ] This bug exists for Objective-C
- [ ] This bug exists for Objective-C++
The code with a problem is:
#elif
It looks like:
#if
It should look like:
WHY?:-
- all conditional Preprocessor Commands, #if, #else, #endif, #ifdef, #ifndef are inside keyword.control.directive.conditional (eg. keyword.control.directive.conditional.ifdef)
- But #elif is inside keyword.control.directive, (like this: keyword.control.directive.elif)
- Shouldn't #elif's textmate scope be under keyword.control.directive.conditional too like the others?
I have fixed this by modifying cpp.tmLanguage.json At Line 12683 if you add elif beside the other #if #ifdef #ifndef preprocessor commands, this gets fixed
I believe I am experiencing this bug, but found the report to be insufficient. I'll add the missing information:
The code with a problem is:
#if FOO // Coloration of expression is as expected
#elif BAZ // Coloration of expression is NOT as expected
#endif
It looks like:
Using "Dark+" theme:

It should look like:

I believe the incorrect code is now located here:
https://github.com/jeff-hykin/better-cpp-syntax/blob/8d51203e1a95a3e8bcb122ca8bc984eceec675b1/syntaxes/cpp.tmLanguage.json#L12806
I applied the suggested patch there and found it resulted in the expected highlighting.