mirror of
https://github.com/vlang/v.git
synced 2025-09-09 07:15:50 -04:00
fmt: simplify formatting struct field comments (#19373)
This commit is contained in:
parent
ec0d5dd258
commit
e1a48d6c2e
@ -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 {
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user