GtkSourceContextEngine: contexts from different languages do not retain styling in aggregatation
(Tested with gtksourceview 4.4.0, gedit 3.34.0, Ubuntu 19.10)
If test-a.lang replaces def:c-like-comment-multiline
(note: style-ref="warning"
):
<context id="test-a-c-like-comment-multiline" style-ref="warning">
<start>/\*</start>
<end>\*/</end>
</context>
<replace id="def:c-like-comment-multiline" ref="test-a-c-like-comment-multiline"/>
and test-b.lang also replaces def:c-like-comment-multiline
(note: style-ref="error"
):
<context id="test-b-c-like-comment-multiline" style-ref="error">
<start>/\*</start>
<end>\*/</end>
</context>
<replace id="def:c-like-comment-multiline" ref="test-b-c-like-comment-multiline"/>
then, when the definitions are used separately there is no issue.
Highlighted with test-a.lang:
Highlighted with test-b.lang:
But if these two definitions are referenced by an "aggregate" language (test.lang):
<context id="test-a">
<start>test-a {</start>
<end>}</end>
<include>
<context ref="test-a:test-a"/>
</include>
</context>
<context id="test-b">
<start>test-b {</start>
<end>}</end>
<include>
<context ref="test-b:test-b"/>
</include>
</context>
<context id="test" class="no-spell-check">
<include>
<context ref="def:c-like-comment-multiline"/>
<context ref="test-a"/>
<context ref="test-b"/>
</include>
</context>
then one of the replacement contexts (the "last" one, in some order) will be used for all three languages:
This is probably working as designed, but I thought I should document this behaviour anyway.
(I encountered this while working on the HTML/CSS/JS definitions - html.lang references css.lang and javascript.lang to highlight code in <style>
and <script>
elements.)
This may become a more serious issue if there are more aggregate languages, e.g. if markdown.lang starts using other language definitions to highlight code in fenced code blocks:
```css
body { color: red; }
```
Test files: