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 { for i, item := range l.List {
if item.Pos().Line != l.Lbrack.Line { if item.Pos().Line != l.Lbrack.Line {
// not same line // multiline list, add newline before we add each item
buf.WriteByte(newline) buf.WriteByte(newline)
} // also indent each line
buf.Write(p.indent(p.output(item))) buf.Write(p.indent(p.output(item)))
} else {
buf.Write(p.output(item))
}
if i != len(l.List)-1 { if i != len(l.List)-1 {
buf.WriteString(",") buf.WriteString(",")

View File

@ -3,6 +3,8 @@ variable "foo" {
description = "bar" description = "bar"
} }
developer = ["fatih", "arslan"]
provider "aws" { provider "aws" {
access_key = "foo" access_key = "foo"
secret_key = "bar" secret_key = "bar"
@ -31,7 +33,7 @@ resource aws_instance "web" {
resource "aws_instance" "db" { resource "aws_instance" "db" {
security_groups = "${aws_security_group.firewall.*.id}" security_groups = "${aws_security_group.firewall.*.id}"
VPC = "foo" VPC = "foo"
depends_on = [ "aws_instance.web"] depends_on = ["aws_instance.web"]
} }
output "web_ip" { output "web_ip" {

View File

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