Sublime Forum

Repeated scopes and syntax highlighting

#1

Is it possible to reuse a previously applied scope when nesting scopes? For example, let’s say I have the following syntax where the red, green, and blue scopes are highlighted accordingly:

- match: \{
  push:
    - meta_scope: red
    - match: \
      push:
        - meta_scope: green
        - match: \(
          push:
            - meta_scope: blue
            - match: \)
              pop: true
        - match: \]
          pop: true
    - match: \}
      pop: true

Let’s say the input looks like this:
{text[text(text)text]text}

With the syntax definition above, I get the correct highlighting:
{text[text/colortext]text}

If I change the innermost meta_scope to be ‘red’ instead of ‘blue’ I would expect the following:
{text[text/colortext]text}

However, the actual output looks like this:
{text[text(text)text]text}

I’ve verified that the scopes are (red green red) with ctrl+shift+alt+p. I figured the top / last-applied scope would be used in syntax highlighting; however, it appears this is only true when scopes in the stack are unique. Am I misunderstanding how things are supposed to work? I’m using build 3095.

0 Likes

Repeated nesting of scopes resulting in wrong syntax highlighting?
[RFC] Specific scopes for punctuations
#2

That looks like a bug to me.

0 Likes