luochen1990 / rainbow

Rainbow Parentheses Improved, shorter code, no level limit, smooth and fast, powerful configuration.
Apache License 2.0
1.78k stars 95 forks source link

Broken #ifdef/#endif match #96

Closed j5shi closed 6 years ago

j5shi commented 6 years ago

Describe the bug

#ifdef __cplusplus
extern "C" {
#endif

the #endif is considered not to match with #ifdef in above C/CPP code.

To Reproduce

Expected behavior

the #endif is should match with #ifdef in above C/CPP code and have the same color.

Screenshots

capture

Additional context

No.

luochen1990 commented 6 years ago

The { after extern "C" is considered as a parenthesis. It seems complicate to avoid this problem.

j5shi commented 6 years ago

But I think we can just left any open parenthese/bracket/brace/... alone if the close part is not found (same for the close part), this is quite simple and reasonable, what do you think? Afterall, this can happen.

luochen1990 commented 6 years ago

Actually, nobody can tell whether there is a right parenthesis following.

j5shi commented 6 years ago

Actually it's not about whether there's a closed parenthesis following or not, it's about nested parenthesis/brackets/braces.

luochen1990 commented 6 years ago

You can replace #ifdef and #endif into ( and ), it's almost the same thing.