As @wbond stated function definitions should be represented by a meta.function and their arguments block as meta.function.parameters with python syntax as an example how to ensure user only sees one meta.function.* at a time. I therefore had a look into python as I need it for my syntax file, too.
I found meta.function and meta.function.parameters overlap on the closing parenthesis of the parameters block.
def function(argument):
# ^^ meta.function
# ^^ meta.function.parameters
I modified row 504 from meta_scope to meta_content_scope to exclude the closing parenthesis.
function-after-parameters:
- meta_content_scope: meta.function.python
The result is that : is no longer in meta.function what causes the question whether this is expected behaviour or a bug of the engine.
I wrote a small syntax example to verify this issue with the result:
meta.section.round with set: ... causes the ) still being included into the left meta_content_scope.meta.section.square with pop: ... causes the ] not being included into the left meta_content_scope.The opening ( or [ is never included in the meta_content_scope. Therefore I expect the closing ) or ] not being included as well no matter how it is left.
%YAML 1.2
---
name: Example
scope: source.example
contexts:
main:
- match: \(
scope: punctuation.section.round.begin
push: example-1
- match: \[
scope: punctuation.section.square.begin
push: example-2
# example 1: leave by 'set'
example-1:
- meta_content_scope: meta.section.round
- match: \)
scope: punctuation.section.round.end
set: after-example-1
after-example-1:
- match: '#'
scope: comment
pop: true
- match: $
pop: true
# example 2: leave by 'pop'
example-2:
- meta_content_scope: meta.meta.section.square
- match: \]
scope: punctuation.section.square.end
pop: true
Yeah meta_content_scope (meta_scope too, maybe?) is a bit iffy with set. I never investigated how it worked in detail though and just fixed the specific issues I had, because I wasn't sure how it was intended to work.
Thanks for the report. I've fixed the Python issue with 60a1dbf140d36a13c3d922285ad6d9927770d5de.
set definitely acts differently in this case than pop/push do in combination. At this point I think this behavior is well embedded in syntaxes, so even if it was something that we wanted to change, I don't think we could, for the sake of backwards compatibility.
Your are totally right @wbond not to change it anymore. If one knows how it works, it's ok. Unfortunately this makes the use of set necessary in some cases where pop would work too, just to get consistent meta-scopes which include the surrounding punctuation.
Most helpful comment
Thanks for the report. I've fixed the Python issue with 60a1dbf140d36a13c3d922285ad6d9927770d5de.
setdefinitely acts differently in this case thanpop/pushdo in combination. At this point I think this behavior is well embedded in syntaxes, so even if it was something that we wanted to change, I don't think we could, for the sake of backwards compatibility.