printer: fix printing of lists
This commit is contained in:
parent
5e525249f3
commit
ccbedaa032
@ -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(",")
|
||||
|
4
printer/testdata/complexhcl.golden
vendored
4
printer/testdata/complexhcl.golden
vendored
@ -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" {
|
||||
|
2
printer/testdata/complexhcl.input
vendored
2
printer/testdata/complexhcl.input
vendored
@ -4,6 +4,8 @@ variable "foo" {
|
||||
description = "bar"
|
||||
}
|
||||
|
||||
developer = [ "fatih", "arslan"]
|
||||
|
||||
provider "aws" {
|
||||
access_key ="foo"
|
||||
secret_key = "bar"
|
||||
|
Loading…
Reference in New Issue
Block a user