We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9fce4e commit c9a8d64Copy full SHA for c9a8d64
vlib/v/fmt/fmt.v
@@ -2097,7 +2097,13 @@ pub fn (mut f Fmt) map_init(node ast.MapInit) {
2097
f.mark_types_import_as_used(info.key_type)
2098
f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias))
2099
}
2100
- f.write('{}')
+ if node.pos.line_nr == node.pos.last_line {
2101
+ f.write('{}')
2102
+ } else {
2103
+ f.writeln('{')
2104
+ f.comments(node.pre_cmnts, level: .indent)
2105
+ f.write('}')
2106
+ }
2107
return
2108
2109
f.writeln('{')
vlib/v/fmt/tests/empty_map_fmt_keep.vv
@@ -0,0 +1,11 @@
1
+struct Foo {
2
+ bar map[int]int
3
+}
4
+
5
+fn main() {
6
+ foo := Foo{
7
+ bar: {
8
+ // comment
9
10
11
0 commit comments