fmt: preserve formatting with comments in a empty map (#13362)
parent
b9fce4ef09
commit
c9a8d6448d
|
@ -2097,7 +2097,13 @@ pub fn (mut f Fmt) map_init(node ast.MapInit) {
|
|||
f.mark_types_import_as_used(info.key_type)
|
||||
f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias))
|
||||
}
|
||||
if node.pos.line_nr == node.pos.last_line {
|
||||
f.write('{}')
|
||||
} else {
|
||||
f.writeln('{')
|
||||
f.comments(node.pre_cmnts, level: .indent)
|
||||
f.write('}')
|
||||
}
|
||||
return
|
||||
}
|
||||
f.writeln('{')
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
struct Foo {
|
||||
bar map[int]int
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo := Foo{
|
||||
bar: {
|
||||
// comment
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue