Skip to content

Commit

Permalink
short assignments dont get a new line in case:
Browse files Browse the repository at this point in the history
  • Loading branch information
asibahi committed Aug 12, 2024
1 parent 70f0694 commit 05dde34
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/odin/printer/visit.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 05dde34

Please sign in to comment.