hclwrite: heredoc tokens are in line.lead, not line.assign (#95)

This commit is contained in:
Kristin Laemmert 2019-03-15 13:19:41 -07:00 committed by GitHub
parent fdf8e232b6
commit 956e03eb6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View File

@ -79,13 +79,13 @@ func formatIndent(lines []formatLine) {
netBrackets := 0 netBrackets := 0
for _, token := range line.lead { for _, token := range line.lead {
netBrackets += tokenBracketChange(token) netBrackets += tokenBracketChange(token)
}
for _, token := range line.assign {
netBrackets += tokenBracketChange(token)
if token.Type == hclsyntax.TokenOHeredoc { if token.Type == hclsyntax.TokenOHeredoc {
inHeredoc = true inHeredoc = true
} }
} }
for _, token := range line.assign {
netBrackets += tokenBracketChange(token)
}
switch { switch {
case netBrackets > 0: case netBrackets > 0:

View File

@ -520,6 +520,30 @@ foo {
${a}${b}${c} ${d} ${a}${b}${c} ${d}
EOT EOT
} }
`,
},
{
`
foo {
bar = <<EOT
Foo bar baz
EOT
}
baz {
default="string"
}
`,
`
foo {
bar = <<EOT
Foo bar baz
EOT
}
baz {
default = "string"
}
`, `,
}, },
} }