diff --git a/hclwrite/format.go b/hclwrite/format.go index 22b1919..f20ae23 100644 --- a/hclwrite/format.go +++ b/hclwrite/format.go @@ -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: diff --git a/hclwrite/format_test.go b/hclwrite/format_test.go index 6615be8..6f64b07 100644 --- a/hclwrite/format_test.go +++ b/hclwrite/format_test.go @@ -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}"`,