Sublime Forum

How does clear_scopes work?

#1

Hey, for fun I’m writing a sublime-syntax based highlighter, but I’m having a hard time understanding how clear_scopes works. The main thing I’m wondering is if when a context containing clear_scopes pops, are the previously cleared scopes restored? Or is the scope stack maintained separately and clear_scopes mutatively pops all of those scopes off? Thanks!

0 Likes

#2

yes, they are.

0 Likes

#3

Thanks for the quick reply! I also take it from the documentation that clear_scopes works like meta_scope in that it encloses pushing and popping matches. My other question is how do all meta properties interact when multiple contexts are pushed at once? It seems like you would get partially overlapping scopes if you pushed a context with a meta_content_scope and a context with a meta_scope at the same time, which isn’t a problem per se but seems wrong because it really complicates implementation (as you can’t just use a stack anymore).

Are the enclosing meta properties (meta_scope and clear_scopes) only used on the first context pushed, with all subsequent contexts just not enclosing the match? Or do they aggregate so that all of the clear scopes run, then all of the meta scopes, then the match itself, then all of the meta content scopes?

I really appreciate your help!

0 Likes