[gtksourceview/gtksourceview-4-2] yaml.lang: fix some cases of falsely recognized map keys
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourceview-4-2] yaml.lang: fix some cases of falsely recognized map keys
- Date: Mon, 29 Apr 2019 21:46:18 +0000 (UTC)
commit 4796ba61ff6bc0fecd7942e465d9109fe9acad14
Author: Роман Донченко <dpb corrigendum ru>
Date: Mon Apr 29 23:06:36 2019 +0300
yaml.lang: fix some cases of falsely recognized map keys
First, don't recognize keys inside of quoted strings. Currently, "a: b"
is recognized as a map entry with `"a` as the key and `b"` as the value.
Fix that by giving the "string" context a higher priority than the "map"
context.
Second, prevent some comments from being recognized as map entries.
Specifically, cases like this:
# foo: bar
Even though the "map" context has lower priority than the "comment"
context, this would still be recognized as a map entry, because the map
regex would match the line starting with the leading space and thus be
the leftmost match. Fix this by requiring the first character of a map
key to not be a whitespace character.
There is still a case where a map entry is recognized where it shouldn't
be:
foo # bar: baz
However, I don't see a way to fix this without running into the
performance problem described in the comment in the "map" context
definition.
data/language-specs/yaml.lang | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/data/language-specs/yaml.lang b/data/language-specs/yaml.lang
index 4f52f8b6..4578bd66 100644
--- a/data/language-specs/yaml.lang
+++ b/data/language-specs/yaml.lang
@@ -189,7 +189,7 @@
<match>(?<=^|\s)((?:[^:]|:(?=\S))+)(?::\s+|:$)</match>
-->
- <match>(?<=^|\s)((?:[^:])+)(?::\s+|:$)</match>
+ <match>(?<=^|\s)([^:\s][^:]*)(?::\s+|:$)</match>
<include>
<context sub-pattern="1" style-ref="map-key"/>
</include>
@@ -223,8 +223,8 @@
<context ref="alias"/>
<context ref="tag"/>
<context ref="anchor"/>
- <context ref="map"/>
<context ref="string"/>
+ <context ref="map"/>
<context ref="unquoted-string"/>
</include>
</context>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]