Fix variable substitution for multiple defaulted vars

The problem was that the python regex engine is strictly left-to-right,
so matching `[^}]|\\}` against \\}} meant that the `\\` was consumed by
the left of the `|`. The solution is to just switch them around.

Also add a way to run python tests from within vim, so we can actually
test this stuff.
This commit is contained in:
Ben Jackson 2021-02-06 20:05:33 +00:00
commit 30eec0d93c
4 changed files with 121 additions and 4 deletions

View file

@ -460,8 +460,8 @@ VAR_MATCH = re.compile(
{(?P<braceddefault> # or An {id:default} - default param, as
(?P<defname>[_a-z][_a-z0-9]*) # an ID
: # then a colon
(?P<default>(?:[^}]|\})*) # then anything up to }, or a \}
)} | #
(?P<default>(?:\\}|[^}])+) # then anything up to }, or a \}
)} | # then a }
(?P<invalid>) # or Something else - invalid
)
""",