Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix highlighting of multi-line bracket expressions #9

Merged
merged 2 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions syntaxes/hcl.tmGrammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,10 @@
},
"patterns": [
{
"include": "#expressions"
"include": "#comments"
},
{
"include": "#local_identifiers"
"include": "#expressions"
}
]
}
Expand Down
17 changes: 17 additions & 0 deletions tests/snapshot/hcl/issue941.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
instance_size = ( #Comment
length(var.instance_size) > 0 ? ( #Comment
var.instance_size #If instance size is provided, use it.
) #Comment
: #Comment
(var.insane_mode ?
lookup(local.insane_mode_instance_size_map, local.cloud, null) #If instance size is not provided and var.insane_mode is true, lookup in this table.
: #
lookup(local.instance_size_map, local.cloud, null) #If instance size is not provided and var.insane_mode is false, lookup in this table.
)
)

# Comment

variable "test" {
default = "test"
}
124 changes: 124 additions & 0 deletions tests/snapshot/hcl/issue941.hcl.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
>instance_size = ( #Comment
#^^^^^^^^^^^^^ source.hcl variable.declaration.hcl variable.other.readwrite.hcl
# ^ source.hcl variable.declaration.hcl
# ^ source.hcl variable.declaration.hcl keyword.operator.assignment.hcl
# ^ source.hcl variable.declaration.hcl
# ^ source.hcl punctuation.section.parens.begin.hcl
# ^^^^^^^^^^^^^^^^^^^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^ source.hcl comment.line.number-sign.hcl
> length(var.instance_size) > 0 ? ( #Comment
#^^ source.hcl
# ^^^^^^ source.hcl meta.function-call.hcl variable.function.hcl
# ^ source.hcl meta.function-call.hcl punctuation.section.parens.begin.hcl
# ^^^ source.hcl meta.function-call.hcl
# ^ source.hcl meta.function-call.hcl keyword.operator.accessor.hcl
# ^^^^^^^^^^^^^ source.hcl meta.function-call.hcl variable.other.member.hcl
# ^ source.hcl meta.function-call.hcl punctuation.section.parens.end.hcl
# ^ source.hcl
# ^ source.hcl keyword.operator.hcl
# ^ source.hcl
# ^ source.hcl constant.numeric.integer.hcl
# ^ source.hcl
# ^ source.hcl keyword.operator.hcl
# ^ source.hcl
# ^ source.hcl punctuation.section.parens.begin.hcl
# ^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^ source.hcl comment.line.number-sign.hcl
> var.instance_size #If instance size is provided, use it.
#^^^^^^^ source.hcl
# ^ source.hcl keyword.operator.accessor.hcl
# ^^^^^^^^^^^^^ source.hcl variable.other.member.hcl
# ^^^^^^^^^^^^^^^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl comment.line.number-sign.hcl
> ) #Comment
#^^ source.hcl
# ^ source.hcl punctuation.section.parens.end.hcl
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^ source.hcl comment.line.number-sign.hcl
> : #Comment
#^^ source.hcl
# ^ source.hcl
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^ source.hcl comment.line.number-sign.hcl
> (var.insane_mode ?
#^^ source.hcl
# ^ source.hcl punctuation.section.parens.begin.hcl
# ^^^ source.hcl
# ^ source.hcl keyword.operator.accessor.hcl
# ^^^^^^^^^^^ source.hcl variable.other.member.hcl
# ^ source.hcl
# ^ source.hcl keyword.operator.hcl
> lookup(local.insane_mode_instance_size_map, local.cloud, null) #If instance size is not provided and var.insane_mode is true, lookup in this table.
#^^^^ source.hcl
# ^^^^^^ source.hcl meta.function-call.hcl variable.function.hcl
# ^ source.hcl meta.function-call.hcl punctuation.section.parens.begin.hcl
# ^^^^^ source.hcl meta.function-call.hcl
# ^ source.hcl meta.function-call.hcl keyword.operator.accessor.hcl
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl meta.function-call.hcl variable.other.member.hcl
# ^ source.hcl meta.function-call.hcl punctuation.separator.hcl
# ^^^^^^ source.hcl meta.function-call.hcl
# ^ source.hcl meta.function-call.hcl keyword.operator.accessor.hcl
# ^^^^^ source.hcl meta.function-call.hcl variable.other.member.hcl
# ^ source.hcl meta.function-call.hcl punctuation.separator.hcl
# ^ source.hcl meta.function-call.hcl
# ^^^^ source.hcl meta.function-call.hcl constant.language.hcl
# ^ source.hcl meta.function-call.hcl punctuation.section.parens.end.hcl
# ^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl comment.line.number-sign.hcl
> : #
#^^^^ source.hcl
# ^ source.hcl
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
> lookup(local.instance_size_map, local.cloud, null) #If instance size is not provided and var.insane_mode is false, lookup in this table.
#^^^^ source.hcl
# ^^^^^^ source.hcl meta.function-call.hcl variable.function.hcl
# ^ source.hcl meta.function-call.hcl punctuation.section.parens.begin.hcl
# ^^^^^ source.hcl meta.function-call.hcl
# ^ source.hcl meta.function-call.hcl keyword.operator.accessor.hcl
# ^^^^^^^^^^^^^^^^^ source.hcl meta.function-call.hcl variable.other.member.hcl
# ^ source.hcl meta.function-call.hcl punctuation.separator.hcl
# ^^^^^^ source.hcl meta.function-call.hcl
# ^ source.hcl meta.function-call.hcl keyword.operator.accessor.hcl
# ^^^^^ source.hcl meta.function-call.hcl variable.other.member.hcl
# ^ source.hcl meta.function-call.hcl punctuation.separator.hcl
# ^ source.hcl meta.function-call.hcl
# ^^^^ source.hcl meta.function-call.hcl constant.language.hcl
# ^ source.hcl meta.function-call.hcl punctuation.section.parens.end.hcl
# ^^^^^^^^^^^^^ source.hcl
# ^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.hcl comment.line.number-sign.hcl
> )
#^^ source.hcl
# ^ source.hcl punctuation.section.parens.end.hcl
>)
#^ source.hcl punctuation.section.parens.end.hcl
>
># Comment
#^ source.hcl comment.line.number-sign.hcl punctuation.definition.comment.hcl
# ^^^^^^^^ source.hcl comment.line.number-sign.hcl
>
>variable "test" {
#^^^^^^^^ source.hcl meta.block.hcl entity.name.type.hcl
# ^ source.hcl meta.block.hcl
# ^^^^^^ source.hcl meta.block.hcl variable.other.enummember.hcl
# ^ source.hcl meta.block.hcl
# ^ source.hcl meta.block.hcl punctuation.section.block.begin.hcl
> default = "test"
#^^ source.hcl meta.block.hcl
# ^^^^^^^ source.hcl meta.block.hcl variable.declaration.hcl variable.other.readwrite.hcl
# ^ source.hcl meta.block.hcl variable.declaration.hcl
# ^ source.hcl meta.block.hcl variable.declaration.hcl keyword.operator.assignment.hcl
# ^ source.hcl meta.block.hcl variable.declaration.hcl
# ^ source.hcl meta.block.hcl string.quoted.double.hcl punctuation.definition.string.begin.hcl
# ^^^^ source.hcl meta.block.hcl string.quoted.double.hcl
# ^ source.hcl meta.block.hcl string.quoted.double.hcl punctuation.definition.string.end.hcl
>}
#^ source.hcl meta.block.hcl punctuation.section.block.end.hcl
>