printer: only align list items if items have comments
This commit is contained in:
parent
c73430cb1e
commit
1ae9933e7d
@ -402,8 +402,14 @@ func (p *printer) list(l *ast.ListType) []byte {
|
|||||||
buf.WriteString(",")
|
buf.WriteString(",")
|
||||||
|
|
||||||
if lit, ok := item.(*ast.LiteralType); ok && lit.LineComment != nil {
|
if lit, ok := item.(*ast.LiteralType); ok && lit.LineComment != nil {
|
||||||
for i := 0; i < longestLine-curLen+1; i++ {
|
// if the next item doesn't have any comments, do not align
|
||||||
buf.WriteByte(blank)
|
buf.WriteByte(blank) // align one space
|
||||||
|
if i != len(l.List)-1 {
|
||||||
|
if lit, ok := l.List[i+1].(*ast.LiteralType); ok && lit.LineComment != nil {
|
||||||
|
for i := 0; i < longestLine-curLen; i++ {
|
||||||
|
buf.WriteByte(blank)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, comment := range lit.LineComment.List {
|
for _, comment := range lit.LineComment.List {
|
||||||
|
Loading…
Reference in New Issue
Block a user