diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-05-16 20:55:46 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-05-16 20:55:46 +0200 |
| commit | e5fa6ba019f5bde0846f096a3523d5fb2664f4ca (patch) | |
| tree | e7a003392e138acca60c00e3c021882cb3a9fb9a /src | |
| parent | 14aedd562d50e37db1ad50d04f0af7d5a0cc5d0e (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, |