[Language definition] Unknown style / context / regex errors when referencing from another definition
(Tested with gtksourceview 4.2.0, gedit 3.32.0, Ubuntu 19.04)
If the first reference to another language definition is one of these cases:
- A style reference:
<context id="..." style-ref="test-inc:style">
- A context reference in a <replace>:
<replace id="..." ref="test-inc:context"/>
- A regex reference:
<match>\%{test-inc:regex}</match>
Then it will result in an error (these are three separate test cases):
(org.gnome.gedit:31743): GtkSourceView-WARNING **: 03:55:07.590: in file /home/jeff/.local/share/gtksourceview-4/language-specs/test-style-reg.lang: style 'test-inc:style' not defined
(org.gnome.gedit:31743): GtkSourceView-WARNING **: 03:55:07.610: Failed to load '/home/jeff/.local/share/gtksourceview-4/language-specs/test-replace.lang': unknown context “test-inc:context”
(org.gnome.gedit:31743): GtkSourceView-WARNING **: 03:55:07.622: Failed to load '/home/jeff/.local/share/gtksourceview-4/language-specs/test-regex.lang': Unknown id “test-inc:regex” in regex “\%{test-inc:regex}”
These errors can be worked around by:
-
Referencing a style from the definition in the <styles> section:
<styles> <style id="..." name="..." map-to="test-inc:style"/> </styles>
-
Or referencing a context from the definition using <context>, before the first actual reference:
<context id="..."> <include> <context ref="test-inc:context"/> </include> </context>
Test cases and helper files:
test-inc.lang
test-replace-helper.lang
test-style-reg.lang
test-regex.lang
test-replace.lang
Edited by Jeffery To