diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-05-16 20:55:46 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-05-16 20:56:58 +0200 |
| commit | e99d7b36013b4fab4defafaef7c9d4cf73d9b94b (patch) | |
| tree | db55f8027b1c2baaaf61ff0138d048d068b1ef47 /src | |
| parent | 30625d5568c085c622deece91ed8ac9e81ba28be (diff) | |
Fix issues with comments in comp literal
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/visit.odin | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index f2e6636..675435e 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -2227,21 +2227,21 @@ visit_expr :: proc( } } - should_newline := - comp_lit_contains_fields(v^) || - contains_comments_in_range(p, v.pos, v.end) + should_newline := comp_lit_contains_fields(v^) + should_newline &= (called_from == .Value_Decl || called_from == .Assignment_Stmt || (called_from == .Call_Expr && comp_lit_contains_blocks(p, v^))) should_newline &= len(v.elems) != 0 + should_newline |= contains_comments_in_range(p, v.pos, v.end) + if should_newline { document = cons_with_nopl( document, visit_begin_brace(p, v.pos, .Comp_Lit), ) - set_source_position(p, v.open) document = cons( document, |