Commit d53e1abb authored by Роман Донченко's avatar Роман Донченко Committed by Christian Hergert

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"

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

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
parent eda6cda0
......@@ -189,7 +189,7 @@
<context sub-pattern="1" style-ref="map-key"/>
......@@ -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"/>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment