diff --git a/src/_main.yml b/src/_main.yml index 0a2d094..28ce74e 100644 --- a/src/_main.yml +++ b/src/_main.yml @@ -271,7 +271,7 @@ repository: name: meta.mapping.key.hcl variable.other.readwrite.hcl "2": name: keyword.operator.assignment.hcl - - match: \b((").*("))\s*(\=)\s* + - match: ^\s*((").*("))\s*(\=)\s* comment: String object key captures: "1": diff --git a/syntaxes/hcl.tmGrammar.json b/syntaxes/hcl.tmGrammar.json index a11dbac..7e5b662 100644 --- a/syntaxes/hcl.tmGrammar.json +++ b/syntaxes/hcl.tmGrammar.json @@ -553,7 +553,7 @@ } }, { - "match": "\\b((\").*(\"))\\s*(\\=)\\s*", + "match": "^\\s*((\").*(\"))\\s*(\\=)\\s*", "comment": "String object key", "captures": { "1": { diff --git a/tests/snapshot/hcl/issue79.hcl b/tests/snapshot/hcl/issue79.hcl index 9952329..3f815b3 100644 --- a/tests/snapshot/hcl/issue79.hcl +++ b/tests/snapshot/hcl/issue79.hcl @@ -4,5 +4,7 @@ block { nested_obj = { attr = var.test attr2 = var.test == "foo" ? "true" : "false" + "attr2" = var.test == "foo" ? "true" : "false" + (attr2) = var.test == "foo" ? "true" : "false" } } \ No newline at end of file diff --git a/tests/snapshot/hcl/issue79.hcl.snap b/tests/snapshot/hcl/issue79.hcl.snap index 1916cf9..872c67c 100644 --- a/tests/snapshot/hcl/issue79.hcl.snap +++ b/tests/snapshot/hcl/issue79.hcl.snap @@ -76,6 +76,57 @@ # ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl # ^^^^^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl # ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +> "attr2" = var.test == "foo" ? "true" : "false" +#^^^^^^^^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^^^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl string.quoted.double.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^^^^^^^^^ source.hcl meta.block.hcl meta.braces.hcl +# ^^ source.hcl meta.block.hcl meta.braces.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^^^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +> (attr2) = var.test == "foo" ? "true" : "false" +#^^^^^^^^^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl punctuation.section.parens.begin.hcl +# ^^^^^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl punctuation.section.parens.end.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl meta.mapping.key.hcl +# ^^^^^^^^^ source.hcl meta.block.hcl meta.braces.hcl +# ^^ source.hcl meta.block.hcl meta.braces.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl keyword.operator.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl +# ^^^^^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl +# ^ source.hcl meta.block.hcl meta.braces.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl > } #^^^^ source.hcl meta.block.hcl meta.braces.hcl # ^ source.hcl meta.block.hcl meta.braces.hcl punctuation.section.braces.end.hcl