printer: only align list items if items have comments
This commit is contained in:
parent
c73430cb1e
commit
1ae9933e7d
@ -402,9 +402,15 @@ func (p *printer) list(l *ast.ListType) []byte {
|
||||
buf.WriteString(",")
|
||||
|
||||
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) // 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 {
|
||||
buf.WriteString(comment.Text)
|
||||
|
Loading…
Reference in New Issue
Block a user