From 3d9d692a24c7a2cf76f6baf0cd664f8db48ae7c6 Mon Sep 17 00:00:00 2001 From: Stephen Weatherford Date: Tue, 16 Jul 2019 15:01:30 -0700 Subject: [PATCH] Fix #250, strings vs expressions boundary cases --- grammars/arm-expression-string.tmLanguage.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grammars/arm-expression-string.tmLanguage.json b/grammars/arm-expression-string.tmLanguage.json index fa510c519..20973f4fd 100644 --- a/grammars/arm-expression-string.tmLanguage.json +++ b/grammars/arm-expression-string.tmLanguage.json @@ -6,6 +6,8 @@ "$preprocessComment2": "The 'builtin' key/value are special - they're created during build from our function metadata", "$preprocessComment3": "Currently you need to run 'build grammars' after changing this file", "preprocess": { + "escaped-json-character": "(?:\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4}))", + "escaped-apostrophe": "(?:[']['])", "idchar": "[_$[:alnum:]]", "id": "(?:[_$[:alpha:]]{{idchar}}*)", "ns-userfunc": "(?:({{id}})\\s*(\\.)\\s*({{id}}))", @@ -42,8 +44,9 @@ "repository": { "expressionstring": { "name": "meta.expression.tle.arm", - "begin": "\"\\[(?!\\[)", - "$beginComment": "A string that starts with [[ is not an expression", + "$begin": "(?x) \"\\[(?!\\[) (?= .*) \\]\"", + "begin": "(?x) \"\\[(?!\\[) (?= ([^\"]|{{escaped-json-character}}|5)* \\]\" )", + "$beginComment": "An expression must start with [ (no whitespace before), not start with [[, and end with ] (no whitespace after)", "end": "\\]\"", "beginCaptures": { "0": {