diff options
| -rw-r--r-- | src/odin/printer/document.odin | 4 | ||||
| -rw-r--r-- | tools/odinfmt/tests/allman/.snapshots/switch.odin | 6 | ||||
| -rw-r--r-- | tools/odinfmt/tests/allman/.snapshots/when.odin | 4 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/odin/printer/document.odin b/src/odin/printer/document.odin index 5fdec78..f3ef61e 100644 --- a/src/odin/printer/document.odin +++ b/src/odin/printer/document.odin @@ -446,6 +446,10 @@ format :: proc(width: int, list: ^[dynamic]Tuple, builder: ^strings.Builder, p: case Document_Newline: if v.amount > 0 { flush_line_suffix(builder, &suffix_builder) + // ensure we strip any misplaced trailing whitespace + for builder.buf[len(builder.buf)-1] == ' ' { + pop(&builder.buf) + } for i := 0; i < v.amount; i += 1 { strings.write_string(builder, p.newline) } diff --git a/tools/odinfmt/tests/allman/.snapshots/switch.odin b/tools/odinfmt/tests/allman/.snapshots/switch.odin index 10f6faf..9e73da7 100644 --- a/tools/odinfmt/tests/allman/.snapshots/switch.odin +++ b/tools/odinfmt/tests/allman/.snapshots/switch.odin @@ -1,16 +1,16 @@ package allman -main :: proc() +main :: proc() { num := 1 - switch num + switch num { case 0: case 1: } - switch num + switch num { case 0: case 1: diff --git a/tools/odinfmt/tests/allman/.snapshots/when.odin b/tools/odinfmt/tests/allman/.snapshots/when.odin index f34307f..1f489a3 100644 --- a/tools/odinfmt/tests/allman/.snapshots/when.odin +++ b/tools/odinfmt/tests/allman/.snapshots/when.odin @@ -1,10 +1,10 @@ package allman -main :: proc() +main :: proc() { TEST_BOOL := false - when TEST_BOOL + when TEST_BOOL { } } |