fmt: keep comment between enum fields (#7566)
parent
270ba07e83
commit
2c0fba5480
|
@ -760,11 +760,12 @@ pub mut:
|
|||
|
||||
pub struct EnumField {
|
||||
pub:
|
||||
name string
|
||||
pos token.Position
|
||||
comments []Comment
|
||||
expr Expr
|
||||
has_expr bool
|
||||
name string
|
||||
pos token.Position
|
||||
comments []Comment
|
||||
next_comments []Comment
|
||||
expr Expr
|
||||
has_expr bool
|
||||
}
|
||||
|
||||
pub struct EnumDecl {
|
||||
|
|
|
@ -739,6 +739,7 @@ pub fn (mut f Fmt) enum_decl(node ast.EnumDecl) {
|
|||
}
|
||||
f.comments(field.comments, inline: true, has_nl: false, level: .indent)
|
||||
f.writeln('')
|
||||
f.comments(field.next_comments, inline: false, has_nl: true, level: .indent)
|
||||
}
|
||||
f.writeln('}\n')
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
enum Abc {
|
||||
a
|
||||
b // after a value
|
||||
c
|
||||
// between values
|
||||
d
|
||||
}
|
||||
|
||||
struct User {
|
||||
name string // name
|
||||
// middle comment
|
||||
|
|
|
@ -1965,7 +1965,8 @@ fn (mut p Parser) enum_decl() ast.EnumDecl {
|
|||
pos: pos
|
||||
expr: expr
|
||||
has_expr: has_expr
|
||||
comments: p.eat_comments()
|
||||
comments: p.eat_line_end_comments()
|
||||
next_comments: p.eat_comments()
|
||||
}
|
||||
}
|
||||
p.top_level_statement_end()
|
||||
|
|
Loading…
Reference in New Issue