printer: fix printing of lists

This commit is contained in:
Fatih Arslan 2015-10-25 19:09:22 +03:00
parent 5e525249f3
commit ccbedaa032
3 changed files with 10 additions and 4 deletions

View File

@ -85,11 +85,13 @@ 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))
}
if i != len(l.List)-1 {
buf.WriteString(",")

View File

@ -3,6 +3,8 @@ variable "foo" {
description = "bar"
}
developer = ["fatih", "arslan"]
provider "aws" {
access_key = "foo"
secret_key = "bar"

View File

@ -4,6 +4,8 @@ variable "foo" {
description = "bar"
}
developer = [ "fatih", "arslan"]
provider "aws" {
access_key ="foo"
secret_key = "bar"