Skip to content

Commit

Permalink
fmt: simplify formatting struct field comments (#19373)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Sep 17, 2023
1 parent ec0d5dd commit e1a48d6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions vlib/v/fmt/struct.v
Expand Up @@ -38,7 +38,6 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) {
field_types << ft
attrs_len := inline_attrs_len(field.attrs)
end_pos := field.pos.pos + field.pos.len
mut comments_len := 0 // Length of comments between field name and type
for comment in field.comments {
if comment.pos.pos >= end_pos {
if comment.pos.line_nr == field.pos.line_nr {
Expand All @@ -48,11 +47,8 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) {
}
continue
}
if comment.pos.pos > field.pos.pos {
comments_len += '/* ${comment.text.trim_left('\x01')} */ '.len
}
}
field_aligns.add_info(comments_len + field.name.len, ft.len, field.pos.line_nr)
field_aligns.add_info(field.name.len, ft.len, field.pos.line_nr)
if field.has_default_expr {
default_expr_aligns.add_info(attrs_len, field_types[i].len, field.pos.line_nr,
use_threshold: true
Expand Down

0 comments on commit e1a48d6

Please sign in to comment.