| author | |
| committer | |
| log | bc24b86d82ec3b8d7d6e7e5d2d3dceb82d7b53dc |
| tree | fbae79c646b4687bf6db4cc5726d9baa6d326751 |
| parent | 029ec456bce5fc6c57eea496db1cebed55e31ede |
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 { |
| 106 | 106 | pub fn popIndent(self: *Self) void { |
| 107 | 107 | assert(self.indent_count != 0); |
| 108 | 108 | 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; | |
| 110 | 112 | } |
| 111 | 113 | |
| 112 | 114 | /// 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" { |
| 3310 | 3310 | ); |
| 3311 | 3311 | } |
| 3312 | 3312 | |
| 3313 | test "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 | ||
| 3313 | 3324 | const std = @import("std"); |
| 3314 | 3325 | const mem = std.mem; |
| 3315 | 3326 | const warn = std.debug.warn; |