mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: fix blank line inserts between enum attribute comments (#18361)
This commit is contained in:
parent
6208b31d9f
commit
bcd5c91bdc
@ -422,6 +422,11 @@ fn (f Fmt) should_insert_newline_before_node(node ast.Node, prev_node ast.Node)
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if stmt is ast.EnumDecl {
|
||||||
|
if stmt.attrs.len > 0 && stmt.attrs[0].pos.line_nr - prev_line_nr <= 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
if stmt is ast.FnDecl {
|
if stmt is ast.FnDecl {
|
||||||
if stmt.attrs.len > 0 && stmt.attrs[0].pos.line_nr - prev_line_nr <= 1 {
|
if stmt.attrs.len > 0 && stmt.attrs[0].pos.line_nr - prev_line_nr <= 1 {
|
||||||
return false
|
return false
|
||||||
|
16
vlib/v/fmt/tests/enum_attributes_keep.vv
Normal file
16
vlib/v/fmt/tests/enum_attributes_keep.vv
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// CollisionType is an enum that categorizes entities for the purpose of collision detection, used in Collider ECS component.
|
||||||
|
// The flag attribute allows for multiple EntityType values to be combined, enabling entities to be categorized as multiple types.
|
||||||
|
[flag]
|
||||||
|
pub enum CollisionType {
|
||||||
|
obstacle
|
||||||
|
chicken
|
||||||
|
egg
|
||||||
|
}
|
||||||
|
|
||||||
|
// Another descriptive comment with a linebreak separated from the next enum decl.
|
||||||
|
|
||||||
|
[flag]
|
||||||
|
pub enum Direction {
|
||||||
|
left
|
||||||
|
right
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user