fmt: fix broken formatting in fn struct fields (#7794)
parent
6bd35505a2
commit
b3de003302
|
@ -622,7 +622,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
|
||||||
max = comments_len + field.name.len
|
max = comments_len + field.name.len
|
||||||
}
|
}
|
||||||
mut ft := f.no_cur_mod(f.table.type_to_str(field.typ))
|
mut ft := f.no_cur_mod(f.table.type_to_str(field.typ))
|
||||||
if !ft.contains('C.') && !ft.contains('JS.') {
|
if !ft.contains('C.') && !ft.contains('JS.') && !ft.contains('fn (') {
|
||||||
ft = f.short_module(ft)
|
ft = f.short_module(ft)
|
||||||
}
|
}
|
||||||
field_types << ft
|
field_types << ft
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import v.ast
|
||||||
|
|
||||||
|
struct Data {
|
||||||
|
a fn (string, voidptr) bool
|
||||||
|
b fn (ast.Stmt, voidptr) bool
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import v.ast
|
||||||
|
|
||||||
|
struct Data {
|
||||||
|
a fn (s string, f voidptr) bool
|
||||||
|
b fn (stmt ast.Stmt, f voidptr) bool
|
||||||
|
}
|
|
@ -744,13 +744,19 @@ pub fn (table &Table) type_to_str_using_aliases(t Type, import_aliases map[strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.function {
|
.function {
|
||||||
if !table.is_fmt {
|
|
||||||
info := sym.info as FnType
|
info := sym.info as FnType
|
||||||
|
if !table.is_fmt {
|
||||||
res = table.fn_signature(info.func, type_only: true)
|
res = table.fn_signature(info.func, type_only: true)
|
||||||
} else {
|
} else {
|
||||||
|
if res.starts_with('fn (') {
|
||||||
|
// fn foo ()
|
||||||
|
res = table.fn_signature(info.func, type_only: true)
|
||||||
|
} else {
|
||||||
|
// FnFoo
|
||||||
res = table.shorten_user_defined_typenames(res, import_aliases)
|
res = table.shorten_user_defined_typenames(res, import_aliases)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.map {
|
.map {
|
||||||
if int(t) == map_type_idx {
|
if int(t) == map_type_idx {
|
||||||
return 'map'
|
return 'map'
|
||||||
|
|
Loading…
Reference in New Issue