diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index cd6a4c67f0..ffc658c906 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -315,14 +315,14 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) { } name := it.name.after('.') f.writeln('enum $name {') - f.comments(it.comments) + f.comments(it.comments, false) for field in it.fields { f.write('\t$field.name') if field.has_expr { f.write(' = ') f.expr(field.expr) } - f.comments(it.comments) + f.comments(field.comments, true) f.writeln('') } f.writeln('}\n') @@ -1100,12 +1100,17 @@ pub fn (mut f Fmt) comment(node ast.Comment) { f.writeln('*/') } -pub fn (mut f Fmt) comments(some_comments []ast.Comment) { +pub fn (mut f Fmt) comments(some_comments []ast.Comment, remove_last_new_line bool) { for c in some_comments { if !f.out.last_n(1)[0].is_space() { f.write('\t') } + f.indent++ f.comment(c) + f.indent-- + } + if remove_last_new_line { + f.remove_new_line() } } @@ -1328,7 +1333,7 @@ pub fn (mut f Fmt) match_expr(it ast.MatchExpr) { f.writeln('}') } } - f.comments(branch.post_comments) + f.comments(branch.post_comments, false) } f.indent-- f.write('}')