better-cpp-syntax icon indicating copy to clipboard operation
better-cpp-syntax copied to clipboard

Using `switch` keyword in macro call breaks `#endif` highlighting (C only)

Open andrjohns opened this issue 5 months ago • 2 comments

Checklist

  • [x] This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"

If Disabling that^ makes the problem go away, then follow this to make an issue on the C++ extension: https://github.com/microsoft/vscode-cpptools/issues/new/choose

The code with a problem is:

#define DEF(name) JS_ATOM_ ## name,

#ifdef DEF
DEF(switch)
#endif

It looks like:

Image

It should look like:

The #endif should be highlighted as valid, as with other keywords:

Image

andrjohns avatar Aug 06 '25 17:08 andrjohns

Just confirmed that the highlighting is correct when treating the file as C++, the above issue only occurs when treating as C

andrjohns avatar Aug 06 '25 17:08 andrjohns

the C repo is here https://github.com/jeff-hykin/better-c-syntax

caused by the switch not having a early cutoff at brackets )

Image

) should be added to the end pattern character class

https://github.com/jeff-hykin/better-c-syntax/blob/ff81a5813673a7be5944e544b2ab83ff8c165a2b/autogenerated/c.tmLanguage.json#L3499

RedCMD avatar Aug 07 '25 02:08 RedCMD