diff --git a/printer/nodes.go b/printer/nodes.go index 2b8d6ae..abd85c1 100644 --- a/printer/nodes.go +++ b/printer/nodes.go @@ -402,8 +402,14 @@ 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++ { - buf.WriteByte(blank) + // 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 {