Skip to content

Commit

Permalink
Fix string object key assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanck committed Mar 22, 2024
1 parent e51615d commit b9d4247
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/hcl.tmGrammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/snapshot/hcl/issue79.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
51 changes: 51 additions & 0 deletions tests/snapshot/hcl/issue79.hcl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b9d4247

Please sign in to comment.