Sublime Forum

CPP macro highlighting bug (unintended interaction w/blocks)

#1

There’s a bug in the way the meta.preprocessor.macro.c and meta.block.c scopes interact. If you use an opening brace inside a macro definition, it will treat the rest of the file as part of the macro definition.

With the default Monokai highlighter, this effect is hidden:

But it shows up if you’ve given the meta.preprocessor scope a different color:

All my code’s pink! You’ll notice that the closing brace in the END macro doesn’t help things. I can’t get the opening brace to stop highlighting stuff, ever. If I hit ctrl+alt+shift+p on the code after the macro definitions, the scopes listed include “meta.preprocessor.macro.c” and “meta.block.c”. It seems the meta.block.c scope is being triggered but for some reason can’t be ended.

If, however, I take out the opening brace, everything returns to normal:

0 Likes