Sublime Forum

[sublime-syntax] Unexpected behaviour of embed in prototype vs. normal contexts

#1

Consider this snippet of code:

#: 
   #:
      #: <use ctrl+alt+shift+p here>
   #:
#:

consider further this two syntaxes meant to be applied to said snippet:

Syntax A:

scope: source
variables:
  comment_dedent: '^(?!\1\s)(?!\s*(#.*)?$)'
contexts:
  prototype:
    - match: '^(\s*)(#:)'
      captures: [ 1: meta.indent, 2: punctuation.definition.comment ]
      embed: dummy
      escape: '{{comment_dedent}}'
    - match: '\s*(#.*)?'
      captures: { 1: comment.line }
  dummy: #ideally, this context should be inlined in the "embed" action
    - meta_content_scope: comment.block
    - match: ''
  main:
    - match: '(?!\s)\s' #this never succeeds, but the rules imported from prototype do

Syntax B:

variables:
  comment_dedent: '^(?!\1\s)(?!\s*(#.*)?$)'
contexts:
  main:
    - match: '^(\s*)(#:)'
      captures: [ 1: meta.indent, 2: punctuation.definition.comment ]
      embed: dummy
      escape: '{{comment_dedent}}'
    - match: '\s*(#.*)?'
      captures: { 1: comment.line }
  dummy: #ideally, this context should be inlined in the "embed" action
    - include: main
    - meta_content_scope: comment.block
    - match: ''

Now, these two syntaxes should be equivalent, but in fact, they arent. If one uses ctrl+alt+shift+p in the indicated line of the snippet, while using syntax a, the scope will be ‘source comment.block comment.block comment.block’. If one instead is using syntax be, the displayed scope will be merely ‘source comment.block’.

Why does this behaviour shows up? I would have expected that both syntaxes produced the result of A, should this assumption be correct? If not, why is so?

0 Likes