printer: improvements on comment aligning
This commit is contained in:
parent
a16955dcad
commit
3a165313db
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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"},
|
||||
}
|
||||
|
||||
|
8
printer/testdata/comment_aligned.golden
vendored
8
printer/testdata/comment_aligned.golden
vendored
@ -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"
|
||||
}
|
||||
|
||||
}
|
6
printer/testdata/comment_aligned.input
vendored
6
printer/testdata/comment_aligned.input
vendored
@ -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"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user