hclwrite: Do not add spaces before template control sequences

This commit is contained in:
Kazuma Watanabe 2019-08-10 06:00:04 +09:00 committed by Martin Atkins
parent 65731f3310
commit 72d32879a5
2 changed files with 5 additions and 1 deletions

View File

@ -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:

View File

@ -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 {}`,