authorgravatar for lachlan@lakebythewoods.xyzLachlan Easton <lachlan@lakebythewoods.xyz> 2020-09-01 13:19:34+10:00
committergravatar for lachlan@lakebythewoods.xyzLachlan Easton <lachlan@lakebythewoods.xyz> 2020-09-01 13:19:34+10:00
logbc24b86d82ec3b8d7d6e7e5d2d3dceb82d7b53dc
treefbae79c646b4687bf6db4cc5726d9baa6d326751
parent029ec456bce5fc6c57eea496db1cebed55e31ede

zig fmt: Fix regression not covered by testing


2 files changed, 14 insertions(+), 1 deletions(-)

lib/std/io/auto_indenting_stream.zig+3-1
......@@ -106,7 +106,9 @@ pub fn AutoIndentingStream(comptime WriterType: type) type {
106106 pub fn popIndent(self: *Self) void {
107107 assert(self.indent_count != 0);
108108 self.indent_count -= 1;
109 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
109
110 if (self.indent_next_line > 0)
111 self.indent_next_line -= 1;
110112 }
111113
112114 /// Writes ' ' bytes if the current line is empty
lib/std/zig/parser_test.zig+11
......@@ -3310,6 +3310,17 @@ test "zig fmt: Only indent multiline string literals in function calls" {
33103310 );
33113311}
33123312
3313test "zig fmt: Don't add extra newline after if" {
3314 try testCanonical(
3315 \\pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path: []const u8) !void {
3316 \\ if (cwd().symLink(existing_path, new_path, .{})) {
3317 \\ return;
3318 \\ }
3319 \\}
3320 \\
3321 );
3322}
3323
33133324const std = @import("std");
33143325const mem = std.mem;
33153326const warn = std.debug.warn;