printer: only align list items if items have comments

This commit is contained in:
Fatih Arslan 2015-11-01 03:29:23 +03:00
parent c73430cb1e
commit 1ae9933e7d

View File

@ -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)