From 72d32879a5c5db881136f801b9efedf19813c081 Mon Sep 17 00:00:00 2001 From: Kazuma Watanabe Date: Sat, 10 Aug 2019 06:00:04 +0900 Subject: [PATCH] hclwrite: Do not add spaces before template control sequences --- hclwrite/format.go | 2 +- hclwrite/format_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hclwrite/format.go b/hclwrite/format.go index ded7fb42..7111ebde 100644 --- a/hclwrite/format.go +++ b/hclwrite/format.go @@ -317,7 +317,7 @@ func spaceAfterToken(subject, before, after *Token) bool { return true // Don't add spaces between interpolated items - case subject.Type == hclsyntax.TokenTemplateSeqEnd && after.Type == hclsyntax.TokenTemplateInterp: + case subject.Type == hclsyntax.TokenTemplateSeqEnd && (after.Type == hclsyntax.TokenTemplateInterp || after.Type == hclsyntax.TokenTemplateControl): return false case tokenBracketChange(subject) > 0: diff --git a/hclwrite/format_test.go b/hclwrite/format_test.go index a9182901..74227691 100644 --- a/hclwrite/format_test.go +++ b/hclwrite/format_test.go @@ -79,6 +79,10 @@ func TestFormat(t *testing.T) { `a="${b}${c}${ d } ${e}"`, `a = "${b}${c}${d} ${e}"`, }, + { + `"%{if true}${var.foo}%{endif}"`, + `"%{if true}${var.foo}%{endif}"`, + }, { `b{}`, `b {}`,