vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Syntax highlighting broken when assigning the value '}' to a member in an enum

Open Il-Capitano opened this issue 7 years ago • 3 comments

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:

010

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".

Il-Capitano avatar Jul 02 '19 13:07 Il-Capitano

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. :)

Colengms avatar Jul 02 '19 17:07 Colengms

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

jeff-hykin avatar Jul 02 '19 17:07 jeff-hykin

Closing, as https://github.com/jeff-hykin/cpp-textmate-grammar/issues/278 has been closed.

Colengms avatar Aug 29 '19 20:08 Colengms