diff --git a/printer/nodes.go b/printer/nodes.go index 689cc56..ecbdba5 100644 --- a/printer/nodes.go +++ b/printer/nodes.go @@ -85,12 +85,14 @@ func (p *printer) list(l *ast.ListType) []byte { for i, item := range l.List { if item.Pos().Line != l.Lbrack.Line { - // not same line + // multiline list, add newline before we add each item buf.WriteByte(newline) + // also indent each line + buf.Write(p.indent(p.output(item))) + } else { + buf.Write(p.output(item)) } - buf.Write(p.indent(p.output(item))) - if i != len(l.List)-1 { buf.WriteString(",") buf.WriteByte(blank) diff --git a/printer/testdata/complexhcl.golden b/printer/testdata/complexhcl.golden index d881e91..f6bd3cb 100644 --- a/printer/testdata/complexhcl.golden +++ b/printer/testdata/complexhcl.golden @@ -3,6 +3,8 @@ variable "foo" { description = "bar" } +developer = ["fatih", "arslan"] + provider "aws" { access_key = "foo" secret_key = "bar" @@ -31,7 +33,7 @@ resource aws_instance "web" { resource "aws_instance" "db" { security_groups = "${aws_security_group.firewall.*.id}" VPC = "foo" - depends_on = [ "aws_instance.web"] + depends_on = ["aws_instance.web"] } output "web_ip" { diff --git a/printer/testdata/complexhcl.input b/printer/testdata/complexhcl.input index fa0ea8e..53b5cd2 100644 --- a/printer/testdata/complexhcl.input +++ b/printer/testdata/complexhcl.input @@ -4,6 +4,8 @@ variable "foo" { description = "bar" } +developer = [ "fatih", "arslan"] + provider "aws" { access_key ="foo" secret_key = "bar"