Skip to content

Commit 9c21e5c

Browse files
committed
std.Progress: always write the output_buffer
Following the commit that made the output_buffer end index become its own field, it's also reasonable to write to the output_buffer even if the terminal field is null.
1 parent 21c61df commit 9c21e5c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/std/Progress.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const assert = std.debug.assert;
1414
const Progress = @This();
1515

1616
/// `null` if the current node (and its children) should
17-
/// not print on update()
17+
/// not print on update(), refreshes the `output_buffer` nonetheless
1818
terminal: ?std.fs.File = undefined,
1919

2020
/// Is this a windows API terminal (note: this is not the same as being run on windows
@@ -350,8 +350,6 @@ fn refreshWithHeldLock(self: *Progress) void {
350350
const is_dumb = !self.supports_ansi_escape_codes and !self.is_windows_terminal;
351351
if (is_dumb and self.dont_print_on_dumb) return;
352352

353-
const file = self.terminal orelse return;
354-
355353
self.end = 0;
356354
self.columns_written = 0;
357355
clearWithHeldLock(self, &self.end);
@@ -360,6 +358,8 @@ fn refreshWithHeldLock(self: *Progress) void {
360358
refreshOutputBufWithHeldLock(self, &self.root, &self.end);
361359
}
362360

361+
const file = self.terminal orelse return;
362+
363363
_ = file.write(self.output_buffer[0..self.end]) catch {
364364
// stop trying to write to this file
365365
self.terminal = null;

0 commit comments

Comments
 (0)