diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 7fd7f1f675..6de03eabec 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1228,7 +1228,7 @@ pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) { f.writeln(x) f.write('*/') } else { - f.write('/* $x */') + f.write('/* ${x.trim(' ')} */') } return } diff --git a/vlib/v/fmt/tests/comments_expected.vv b/vlib/v/fmt/tests/comments_expected.vv index 081ad60164..603e593128 100644 --- a/vlib/v/fmt/tests/comments_expected.vv +++ b/vlib/v/fmt/tests/comments_expected.vv @@ -18,6 +18,10 @@ fn main() { d := c // and an extra one e := c // more comments = more good + arr := [ + /* block foo bar */ /* inline foo bar */ + 0, + ] // before arg comment // after arg comment println('this is a test') diff --git a/vlib/v/fmt/tests/comments_input.vv b/vlib/v/fmt/tests/comments_input.vv index b09b4a4cc4..c53484437c 100644 --- a/vlib/v/fmt/tests/comments_input.vv +++ b/vlib/v/fmt/tests/comments_input.vv @@ -12,6 +12,11 @@ fn main() { d := c // and an extra one e := c // more comments = more good + arr := [ + /* block foo bar */ + // inline foo bar + 0, + ] println(/* before arg comment */ 'this is a test' /* after arg comment */) if /* before if expr */ true /* after if expr */ { println('if')