diff options
| -rw-r--r-- | src/odin/printer/visit.odin | 7 | ||||
| -rw-r--r-- | tools/odinfmt/tests/.snapshots/calls.odin | 14 | ||||
| -rw-r--r-- | tools/odinfmt/tests/calls.odin | 14 |
3 files changed, 31 insertions, 4 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 91652a5..6e07d57 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -329,7 +329,6 @@ visit_decl :: proc(p: ^Printer, decl: ^ast.Decl, called_in_stmt := false) -> ^Do @(private) is_call_expr_nestable :: proc(list: []^ast.Expr) -> bool { - if len(list) == 1 { if _, is_comp := list[0].derived.(^ast.Comp_Lit); is_comp { return false @@ -1216,18 +1215,18 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, called_from: Expr_Called_Type = if is_call_expr_nestable(v.args) { document = cons(document, nest(p.indentation_count, cons(break_with(""), visit_call_exprs(p, v)))) } else { - document = cons(document, cons(break_with(""), visit_call_exprs(p, v))) + document = cons(document, nest_if_break(p.indentation_count, cons(break_with(""), visit_call_exprs(p, v)), "call_expr")) } document = cons(document, cons(break_with(""), text(")"))) //We enforce a break if comments exists inside the call args if contains_comments { - document = enforce_break(document) + document = enforce_break(document, Document_Group_Options { id = "call_expr" }) } else if contains_do { document = enforce_fit(document) } else { - document = group(document) + document = group(document, Document_Group_Options { id = "call_expr" }) } case ^Typeid_Type: document = text("typeid") diff --git a/tools/odinfmt/tests/.snapshots/calls.odin b/tools/odinfmt/tests/.snapshots/calls.odin index 8cba026..d169f9b 100644 --- a/tools/odinfmt/tests/.snapshots/calls.odin +++ b/tools/odinfmt/tests/.snapshots/calls.odin @@ -45,4 +45,18 @@ calls :: proc() { ) + test_2( + Foo{ + field1 = 1, + field2 = "hello", + field3 = 1, + field4 = "world", + field5 = 1, + field6 = "!", + field7 = 1, + field8 = 1, + }, + ) + + } diff --git a/tools/odinfmt/tests/calls.odin b/tools/odinfmt/tests/calls.odin index 59002fb..ae9837b 100644 --- a/tools/odinfmt/tests/calls.odin +++ b/tools/odinfmt/tests/calls.odin @@ -15,4 +15,18 @@ calls :: proc() { result = vk.CreateInsance(my_really_cool_call(aaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, cccccccccccccccccccccccccccccccc, ddddddddddddddddddddddddddddddddddddd)) + + test_2( + Foo{field1 = 1, + field2 = "hello", + field3 = 1, + field4 = "world", + field5 = 1, + field6 = "!", + field7 = 1, + field8 = 1, + }, + ) + + } |