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