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 {
|
if len(oneLines) != 0 {
|
||||||
items := p.alignedItems(oneLines)
|
items := p.alignedItems(oneLines)
|
||||||
buf.Write(p.indent(items))
|
buf.Write(p.indent(items))
|
||||||
|
|
||||||
if index != len(o.List.Items) {
|
if index != len(o.List.Items) {
|
||||||
buf.WriteByte(newline)
|
buf.WriteByte(newline)
|
||||||
}
|
}
|
||||||
@ -183,7 +176,6 @@ func (p *printer) objectType(o *ast.ObjectType) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf.WriteString("}")
|
buf.WriteString("}")
|
||||||
buf.WriteByte(newline)
|
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ type entry struct {
|
|||||||
|
|
||||||
// Use go test -update to create/update the respective golden files.
|
// Use go test -update to create/update the respective golden files.
|
||||||
var data = []entry{
|
var data = []entry{
|
||||||
// {"complexhcl.input", "complexhcl.golden"},
|
{"complexhcl.input", "complexhcl.golden"},
|
||||||
// {"list.input", "list.golden"},
|
{"list.input", "list.golden"},
|
||||||
// {"comment.input", "comment.golden"},
|
{"comment.input", "comment.golden"},
|
||||||
{"comment_aligned.input", "comment_aligned.golden"},
|
{"comment_aligned.input", "comment_aligned.golden"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
printer/testdata/comment.golden
vendored
2
printer/testdata/comment.golden
vendored
@ -20,4 +20,4 @@ variable = {
|
|||||||
// lead comment
|
// lead comment
|
||||||
foo = {
|
foo = {
|
||||||
bar = "fatih" // line comment 2
|
bar = "fatih" // line comment 2
|
||||||
} // line comment 3
|
} // line comment 3
|
10
printer/testdata/comment_aligned.golden
vendored
10
printer/testdata/comment_aligned.golden
vendored
@ -7,12 +7,10 @@ aligned = {
|
|||||||
deneme = {
|
deneme = {
|
||||||
bar = "fatih"
|
bar = "fatih"
|
||||||
}
|
}
|
||||||
|
bar = "bar" # yoo3
|
||||||
|
fatih = ["fatih", "arslan"] // yoo4
|
||||||
|
|
||||||
projects = ["vim-go"] # yoo5
|
deneme = {
|
||||||
default = "foo" # yoo6
|
|
||||||
|
|
||||||
example = {
|
|
||||||
bar = "fatih"
|
bar = "fatih"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
6
printer/testdata/comment_aligned.input
vendored
6
printer/testdata/comment_aligned.input
vendored
@ -6,9 +6,9 @@ aligned {
|
|||||||
deneme = {
|
deneme = {
|
||||||
bar = "fatih"
|
bar = "fatih"
|
||||||
}
|
}
|
||||||
projects = ["vim-go"] # yoo5
|
bar = "bar" # yoo3
|
||||||
default = "foo" # yoo6
|
fatih = ["fatih", "arslan"] // yoo4
|
||||||
example = {
|
deneme = {
|
||||||
bar = "fatih"
|
bar = "fatih"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user