Skip to content

Commit bcd5c91

Browse files
authored
fmt: fix blank line inserts between enum attribute comments (#18361)
1 parent 6208b31 commit bcd5c91

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

vlib/v/fmt/fmt.v

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ fn (f Fmt) should_insert_newline_before_node(node ast.Node, prev_node ast.Node)
422422
return false
423423
}
424424
}
425+
if stmt is ast.EnumDecl {
426+
if stmt.attrs.len > 0 && stmt.attrs[0].pos.line_nr - prev_line_nr <= 1 {
427+
return false
428+
}
429+
}
425430
if stmt is ast.FnDecl {
426431
if stmt.attrs.len > 0 && stmt.attrs[0].pos.line_nr - prev_line_nr <= 1 {
427432
return false
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// CollisionType is an enum that categorizes entities for the purpose of collision detection, used in Collider ECS component.
2+
// The flag attribute allows for multiple EntityType values to be combined, enabling entities to be categorized as multiple types.
3+
[flag]
4+
pub enum CollisionType {
5+
obstacle
6+
chicken
7+
egg
8+
}
9+
10+
// Another descriptive comment with a linebreak separated from the next enum decl.
11+
12+
[flag]
13+
pub enum Direction {
14+
left
15+
right
16+
}

0 commit comments

Comments
 (0)