From 956e03eb6ddaa1e736001b4aaa057fe5a33ef57f Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Fri, 15 Mar 2019 13:19:41 -0700 Subject: [PATCH] hclwrite: heredoc tokens are in line.lead, not line.assign (#95) --- hclwrite/format.go | 6 +++--- hclwrite/format_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/hclwrite/format.go b/hclwrite/format.go index eed0694..22b1919 100644 --- a/hclwrite/format.go +++ b/hclwrite/format.go @@ -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: diff --git a/hclwrite/format_test.go b/hclwrite/format_test.go index c07be97..6615be8 100644 --- a/hclwrite/format_test.go +++ b/hclwrite/format_test.go @@ -520,6 +520,30 @@ foo { ${a}${b}${c} ${d} EOT } +`, + }, + { + ` +foo { +bar = <