Skip to content

Commit

Permalink
fix comments of struct init fields and change related fmt test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Aug 11, 2024
1 parent 2dc7f56 commit 10f8379
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion vlib/v/fmt/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ pub fn (mut f Fmt) struct_init(node ast.StructInit) {
f.expr(init_field.expr)
if init_field.comments.len > 0 {
f.write(strings.repeat(` `, comment_align.max_len(init_field.pos.line_nr) - init_field.expr.str().len))
f.comments(init_field.comments, same_line: true, has_nl: false, level: .indent)
f.write(' ')
f.comments(init_field.comments, has_nl: false, level: .indent)
}
if single_line_fields {
if i < node.init_fields.len - 1 {
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/fmt/tests/struct_init_with_comments_keep.vv
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub fn new_builder(initial_size int) Builder {
return Builder{
// buf: make(0, initial_size)
buf: []u8{cap: initial_size}
str_calls: 0 // after str_calls
len: 0 // after len
str_calls: 0 // after str_calls
len: 0 // after len
initial_size: initial_size // final
}
}

0 comments on commit 10f8379

Please sign in to comment.