Sublime Forum

Problem with clear_scopes and BracketHighlighter

#21

This definitely feels like something that should be solved with meta scopes. Honestly, tooling shouldn’t be relying at all (IMO) on the “main” scopes because those can get funged by clear_scopes, overlapping embedded scopes (e.g. when embedding within another language), and even just changes to the mode definition.

The problem of course is that meta scopes aren’t anywhere near universally applied right now, and where they are applied, it’s somewhat inconsistent.

On the subject of clear_scopes though… It is my opinion that clear_scopes: true is an anti-pattern and should be avoided whenever possible. What that declaration basically says is “take a nuclear hammer to all the carefully-curated stuff that I don’t control”. I much prefer the more targeted clear_scopes: 1 (or similar integer), so that the scopes you’re removing are locally-controlled and you don’t accidentally remove something more important from your distant parent contexts (e.g. a function body meta scope).

2 Likes

#22

BH probably won’t care about stacked scopes. If it is in a string, it is in a string. This will follow the current legacy model. In the future we might add more complexity for nested scoping, but right now, all I’m concerned about is matching legacy support.

So theoretically, it will be solved and handled when all syntax files incorporate meta string scopes when nuking parent scopes and when BH ads support for these new meta scopes.

1 Like