Syntax highlighting broken when assigning the value '}' to a member in an enum
Type: bug
Describe the bug
- OS and Version: Windows 10
- VS Code Version: 1.35.1
- C/C++ Extension Versions: 0.23.0 - 0.24.0-insiders3 (possibly all are affected)
- Other extensions you installed (and if the issue persists after disabling them): none
When assigning the value '}' to an element in an enum or enum class the syntax highlighting is broken, it seems to think that the closing curly brace is the end of the enum scope.
To Reproduce
Open a cpp file and paste the following code:
enum
{
a = '}'
};
You should get something like this:
In the screenshot the cursor is on the }, which is highlighted as a closing bracket.
Expected behavior
The expected behaviour is to highlight the '}' as a character literal.
Additional context
The issue persists with the 0.24.0 insiders build, using "C_Cpp.enhancedColorization": "Enabled".
Hi @Il-Capitano . Thanks for reporting this. There appear to be 3 issues here. The character constant is not colored correctly, brace-matching is broken, and later code is colored incorrectly with the string constant color. I believe these issues are related to the Text Mate grammar for C/C++, in VS Code. @jeff-hykin has contributed to C/C++ grammar, and may be able to assist. :)
Yup this is a bug, and a very strange one (the } in the string should be completely invisible to the external pattern). I've created an issue to track it here
Closing, as https://github.com/jeff-hykin/cpp-textmate-grammar/issues/278 has been closed.