Skip to content

Commit

Permalink
hclwrite: Do not add spaces before template control sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored and apparentlymart committed Aug 9, 2019
1 parent 65731f3 commit 72d3287
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hclwrite/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions hclwrite/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}`,
Expand Down

0 comments on commit 72d3287

Please sign in to comment.