hclwrite: No spaces before ... marker in argument lists or for exprs

This commit is contained in:
Martin Atkins 2019-05-15 15:32:00 -07:00
parent d1ed8ee699
commit 4b22149b7c
2 changed files with 6 additions and 2 deletions

View File

@ -248,8 +248,8 @@ func spaceAfterToken(subject, before, after *Token) bool {
// Don't use spaces around attribute access dots
return false
case after.Type == hclsyntax.TokenComma:
// No space right before a comma in an argument list
case after.Type == hclsyntax.TokenComma || after.Type == hclsyntax.TokenEllipsis:
// No space right before a comma or ... in an argument list
return false
case subject.Type == hclsyntax.TokenComma:

View File

@ -63,6 +63,10 @@ func TestFormat(t *testing.T) {
`foo(1, -2,a*b, b,c)`,
`foo(1, -2, a * b, b, c)`,
},
{
`foo(a,b...)`,
`foo(a, b...)`,
},
{
`a="hello ${ name }"`,
`a = "hello ${name}"`,