diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 8a4f35486a..5cc8513874 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1832,8 +1832,10 @@ pub fn (mut f Fmt) array_init(node ast.ArrayInit) { set_comma = true } if cmt.pos.line_nr > expr_pos.last_line { + embed := i + 1 < node.exprs.len + && node.exprs[i + 1].position().line_nr == cmt.pos.last_line f.writeln('') - f.comment(cmt, {}) + f.comment(cmt, iembed: embed) } else { f.write(' ') f.comment(cmt, iembed: true) diff --git a/vlib/v/fmt/tests/comments_array_keep.vv b/vlib/v/fmt/tests/comments_array_keep.vv index 8ccf2fb789..2ff6c13c52 100644 --- a/vlib/v/fmt/tests/comments_array_keep.vv +++ b/vlib/v/fmt/tests/comments_array_keep.vv @@ -68,3 +68,9 @@ fn keep_real_block_comment() { 'eggs', ] } + +fn comment_at_line_start_with_expressions_after() { + arr := [123456789012345, 234567890123456, 678901234567890, 789012345678901, /* at the end */ + 345678901234567, /* in between */ 456789012345678, + /* line start */ 567890123456789, 890123456789012] +}