mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: keep comments in struct init without fields (#7212)
This commit is contained in:
parent
ada02d4498
commit
0e7192c9b7
@ -1829,8 +1829,14 @@ pub fn (mut f Fmt) struct_init(it ast.StructInit) {
|
||||
name = ''
|
||||
}
|
||||
if it.fields.len == 0 {
|
||||
// `Foo{}` on one line if there are no fields
|
||||
f.write('$name{}')
|
||||
// `Foo{}` on one line if there are no fields or comments
|
||||
if it.pre_comments.len == 0 {
|
||||
f.write('$name{}')
|
||||
} else {
|
||||
f.writeln('$name{')
|
||||
f.comments(it.pre_comments, inline: true, has_nl: true, level: .indent)
|
||||
f.write('}')
|
||||
}
|
||||
} else if it.is_short {
|
||||
// `Foo{1,2,3}` (short syntax )
|
||||
// if name != '' {
|
||||
|
@ -24,4 +24,7 @@ fn main() {
|
||||
// after age line
|
||||
// after line2
|
||||
}
|
||||
_ := User{
|
||||
// Just a comment
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user