"extend-parent" attribute inherited by child contexts in container contexts
I encounter a difficulty while building a container context that should end with its parent context, but not its children. This is related to #40 (closed) and !88 (merged).
In sh.lang, let consider for instance the echo
command as a container context, including in particular "single-quoted-string" context, like this (minimalist example):
<context id="echo-command" end-at-line-end="true" extend-parent="false">
<start>\becho\b</start>
<end>;</end>
<include>
<context sub-pattern="0" where="start" style-ref="keyword"/>
<context sub-pattern="0" where="end" style-ref="keyword"/>
<context ref="single-quoted-string"/>
</include>
</context>
where "single-quoted-string" context is simply defined by
<context id="single-quoted-string" style-ref="string" class="string" class-disabled="no-spell-check">
<start>'</start>
<end>'</end>
</context>
Then, include this context in "subshell" context, like this:
<context id="subshell">
<start>\(</start>
<end>\)</end>
<include>
<context sub-pattern="0" where="start" style-ref="keyword"/>
<context sub-pattern="0" where="end" style-ref="keyword"/>
<context ref="echo-command"/>
</include>
</context>
Now, if we try to highlight, in a .sh
file, an expression like
(echo 'some text') && cmd
there is no problem: the "echo-command" context ends with its "subshell" parent context, and the rest of the file is properly highlighted.
But if we try this:
(echo ')') && cmd
then the "subshell" parent context of "echo-command" context takes precedence over "single-quoted-string" context, although this one does not have "extend-parent" attribute set to false, nor recognizes )
as special character. The "subshell" context simply catches the first )
it finds in "echo-command" context, without regards to whether this )
lies in a child context of "echo-command" context or not (and without regards to attributes and/or children contexts of this eventual child context).
Is this behavior a bug, and if not, how to deal with it to properly define a container context like the "echo-command" context above (ending with its parent context but only "at level 0")?
I mention that I tried, among other combinations, to remove "extend-parent" attribute and add )
as an ending character (like this: <end>;\)</end>
), but it does not work, because of conflicts between "subshell" context and "echo-command" context that share thenceforth the same start/end keywords.