diff options
| author | Abdul Rahman Sibahi <asibahi@users.noreply.github.com> | 2024-08-12 15:33:29 +0300 |
|---|---|---|
| committer | Abdul Rahman Sibahi <asibahi@users.noreply.github.com> | 2024-08-12 15:33:29 +0300 |
| commit | 05dde34883b77b832d5bfe556a0202c2c113e30d (patch) | |
| tree | b6b206b11420921f0c2ec4b50e23ec8b28974d98 /src | |
| parent | 70f0694884dea60a9bd1677c735483c90440751c (diff) | |
short assignments dont get a new line in `case:`
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/visit.odin | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 8c82a21..95d5dbd 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1035,9 +1035,14 @@ visit_stmt :: proc( document = cons(document, text(v.terminator.text)) - if len(v.body) != 0 { + if count := len(v.body); count > 0 { set_source_position(p, v.body[0].pos) - document = cons(document, nest(cons(newline(1), visit_block_stmts(p, v.body)))) + fst_stmt, is_assign := v.body[0].derived_stmt.(^Assign_Stmt) + if is_assign && count == 1 { + document = cons_with_opl(document, nest(visit_stmt(p, fst_stmt))) + } else { + document = cons(document, nest(cons(newline(1), visit_block_stmts(p, v.body)))) + } } case ^Type_Switch_Stmt: if v.partial { |