mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
fmt: check for extra newline at end of file
`anything_changed` checks if `source_index` == `source.len` Fixes #2074
This commit is contained in:
parent
51be449a57
commit
5942797000
@ -517,6 +517,18 @@ test "zig fmt: no trailing comma on struct decl" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: extra newlines at the end" {
|
||||
try testTransform(
|
||||
\\const a = b;
|
||||
\\
|
||||
\\
|
||||
\\
|
||||
,
|
||||
\\const a = b;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: simple asm" {
|
||||
try testTransform(
|
||||
\\comptime {
|
||||
|
||||
@ -59,6 +59,10 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@typeOf(
|
||||
|
||||
try renderRoot(allocator, &my_stream.stream, tree);
|
||||
|
||||
if (!anything_changed and my_stream.source_index != my_stream.source.len) {
|
||||
anything_changed = true;
|
||||
}
|
||||
|
||||
return anything_changed;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user