mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 04:25:05 +00:00
zig fmt: Fix regression not covered by testing
This commit is contained in:
parent
029ec456bc
commit
bc24b86d82
@ -106,7 +106,9 @@ pub fn AutoIndentingStream(comptime WriterType: type) type {
|
||||
pub fn popIndent(self: *Self) void {
|
||||
assert(self.indent_count != 0);
|
||||
self.indent_count -= 1;
|
||||
self.indent_next_line = std.math.min(self.indent_count, self.indent_next_line); // Tentative indent may have been popped before there was a newline
|
||||
|
||||
if (self.indent_next_line > 0)
|
||||
self.indent_next_line -= 1;
|
||||
}
|
||||
|
||||
/// Writes ' ' bytes if the current line is empty
|
||||
|
||||
@ -3310,6 +3310,17 @@ test "zig fmt: Only indent multiline string literals in function calls" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: Don't add extra newline after if" {
|
||||
try testCanonical(
|
||||
\\pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path: []const u8) !void {
|
||||
\\ if (cwd().symLink(existing_path, new_path, .{})) {
|
||||
\\ return;
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const warn = std.debug.warn;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user