Sublime Forum

With_prototype not popping context

#1

I’ve had a .sublime_syntax for a markdown-type (really, orgmode-type) text language, it’s worked for awhile, but it broke in the last update (3207).

This used to push lua and then pop it:

- match: ^#!+lua.*$
  push: Packages/Lua/Lua.sublime-syntax
  scope: comment.line.orb
  with_prototype:
    - match: ^#/+lua.*$
      scope: comment.line.orb
      pop:   true

For whatever reason, it’s stopped working. The #/lua line is comment-highlighted, but the Lua parser keeps chugging along.

Any guesses?

0 Likes

#2

Here’s a screenshot showing the problem:

0 Likes

#3

Instead of with_prototype, you should use the new-ish embed/escape. This is more performant and less sensitive to implementation details of the embedded syntax. Example:

- match: ^#!+lua.*$
  scope: comment.line.orb
  embed: Packages/Lua/Lua.sublime-syntax
  escape: ^#/+lua.*$
  escape_captures:
    0: comment.line.orb
2 Likes

#4

Thanks, that pretty much fixed it!

I did have to modify one line like so:

escape: ^(#/+lua.*)$

So that there’s a capture to highlight (putting this here in case someone else runs into this problem)

0 Likes

#5

I should have said 0: comment.line.orb. This avoids the need for the explicit capture group. I’ve corrected my last comment.

0 Likes

#6

Ah, that’s handy. Thanks again!

0 Likes