| author | |
| committer | |
| log | 5942797000936394a7ed68806df56c02ca5d2b44 |
| tree | 3391f0e5b08b79c89103819ea561d123fdb9d808 |
| parent | 51be449a57010a27382cb8104740b34f7863876b |
`anything_changed` checks if `source_index` == `source.len`
Fixes #20742 files changed, 16 insertions(+), 0 deletions(-)
std/zig/parser_test.zig+12| ... | @@ -517,6 +517,18 @@ test "zig fmt: no trailing comma on struct decl" { | ... | @@ -517,6 +517,18 @@ test "zig fmt: no trailing comma on struct decl" { |
| 517 | ); | 517 | ); |
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | test "zig fmt: extra newlines at the end" { | ||
| 521 | try testTransform( | ||
| 522 | \\const a = b; | ||
| 523 | \\ | ||
| 524 | \\ | ||
| 525 | \\ | ||
| 526 | , | ||
| 527 | \\const a = b; | ||
| 528 | \\ | ||
| 529 | ); | ||
| 530 | } | ||
| 531 | |||
| 520 | test "zig fmt: simple asm" { | 532 | test "zig fmt: simple asm" { |
| 521 | try testTransform( | 533 | try testTransform( |
| 522 | \\comptime { | 534 | \\comptime { |
std/zig/render.zig+4| ... | @@ -59,6 +59,10 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@typeOf( | ... | @@ -59,6 +59,10 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@typeOf( |
| 59 | 59 | ||
| 60 | try renderRoot(allocator, &my_stream.stream, tree); | 60 | try renderRoot(allocator, &my_stream.stream, tree); |
| 61 | 61 | ||
| 62 | if (!anything_changed and my_stream.source_index != my_stream.source.len) { | ||
| 63 | anything_changed = true; | ||
| 64 | } | ||
| 65 | |||
| 62 | return anything_changed; | 66 | return anything_changed; |
| 63 | } | 67 | } |
| 64 | 68 |