Skip to content

Commit

Permalink
hclwrite: heredoc tokens are in line.lead, not line.assign (hashicorp#95
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mildwonkey committed Mar 15, 2019
1 parent fdf8e23 commit 956e03e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hclwrite/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ func formatIndent(lines []formatLine) {
netBrackets := 0
for _, token := range line.lead {
netBrackets += tokenBracketChange(token)
}
for _, token := range line.assign {
netBrackets += tokenBracketChange(token)
if token.Type == hclsyntax.TokenOHeredoc {
inHeredoc = true
}
}
for _, token := range line.assign {
netBrackets += tokenBracketChange(token)
}

switch {
case netBrackets > 0:
Expand Down
24 changes: 24 additions & 0 deletions hclwrite/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,30 @@ foo {
${a}${b}${c} ${d}
EOT
}
`,
},
{
`
foo {
bar = <<EOT
Foo bar baz
EOT
}
baz {
default="string"
}
`,
`
foo {
bar = <<EOT
Foo bar baz
EOT
}
baz {
default = "string"
}
`,
},
}
Expand Down

0 comments on commit 956e03e

Please sign in to comment.