summaryrefslogtreecommitdiff
path: root/hclwrite
diff options
context:
space:
mode:
authorKristin Laemmert <mildwonkey@users.noreply.github.com>2019-03-15 13:19:41 -0700
committerGitHub <noreply@github.com>2019-03-15 13:19:41 -0700
commit956e03eb6ddaa1e736001b4aaa057fe5a33ef57f (patch)
tree5798af1fb0ba6aa35bb6a1a6c32ebf7c19c79c31 /hclwrite
parentfdf8e232b64f68d5335fa1be449b0160dadacdb5 (diff)
hclwrite: heredoc tokens are in line.lead, not line.assign (#95)
Diffstat (limited to 'hclwrite')
-rw-r--r--hclwrite/format.go6
-rw-r--r--hclwrite/format_test.go24
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
@@ -522,6 +522,30 @@ EOT
}
`,
},
+ {
+ `
+foo {
+bar = <<EOT
+Foo bar baz
+EOT
+}
+
+baz {
+default="string"
+}
+`,
+ `
+foo {
+ bar = <<EOT
+Foo bar baz
+EOT
+}
+
+baz {
+ default = "string"
+}
+`,
+ },
}
for i, test := range tests {