printer: improvements on comment aligning

This commit is contained in:
Fatih Arslan 2015-10-28 01:07:37 +03:00
parent a16955dcad
commit 3a165313db
5 changed files with 11 additions and 21 deletions

View File

@ -158,16 +158,9 @@ func (p *printer) objectType(o *ast.ObjectType) []byte {
}
}
// fmt.Printf("len(oneLines) = %+v\n", len(oneLines))
// for _, i := range oneLines {
// a := i.Keys[0]
// fmt.Printf("a = %+v\n", a)
// }
if len(oneLines) != 0 {
items := p.alignedItems(oneLines)
buf.Write(p.indent(items))
if index != len(o.List.Items) {
buf.WriteByte(newline)
}
@ -183,7 +176,6 @@ func (p *printer) objectType(o *ast.ObjectType) []byte {
}
buf.WriteString("}")
buf.WriteByte(newline)
return buf.Bytes()
}

View File

@ -24,9 +24,9 @@ type entry struct {
// Use go test -update to create/update the respective golden files.
var data = []entry{
// {"complexhcl.input", "complexhcl.golden"},
// {"list.input", "list.golden"},
// {"comment.input", "comment.golden"},
{"complexhcl.input", "complexhcl.golden"},
{"list.input", "list.golden"},
{"comment.input", "comment.golden"},
{"comment_aligned.input", "comment_aligned.golden"},
}

View File

@ -20,4 +20,4 @@ variable = {
// lead comment
foo = {
bar = "fatih" // line comment 2
} // line comment 3
} // line comment 3

View File

@ -7,12 +7,10 @@ aligned = {
deneme = {
bar = "fatih"
}
bar = "bar" # yoo3
fatih = ["fatih", "arslan"] // yoo4
projects = ["vim-go"] # yoo5
default = "foo" # yoo6
example = {
deneme = {
bar = "fatih"
}
}
}

View File

@ -6,9 +6,9 @@ aligned {
deneme = {
bar = "fatih"
}
projects = ["vim-go"] # yoo5
default = "foo" # yoo6
example = {
bar = "bar" # yoo3
fatih = ["fatih", "arslan"] // yoo4
deneme = {
bar = "fatih"
}
}