diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index 921b0ce251..bb3d1cc2a2 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -908,13 +908,13 @@ fn computeNode( global_progress.newline_count += 1; } - if (global_progress.newline_count < global_progress.rows) { + if (global_progress.withinRowLimit()) { if (children[@intFromEnum(node_index)].child.unwrap()) |child| { i = computeNode(buf, i, serialized, children, child); } } - if (global_progress.newline_count < global_progress.rows) { + if (global_progress.withinRowLimit()) { if (children[@intFromEnum(node_index)].sibling.unwrap()) |sibling| { i = computeNode(buf, i, serialized, children, sibling); } @@ -923,6 +923,11 @@ fn computeNode( return i; } +fn withinRowLimit(p: *Progress) bool { + // The +1 here is so that the PS1 is not scrolled off the top of the terminal. + return p.newline_count + 1 < p.rows; +} + fn write(buf: []const u8) void { const tty = global_progress.terminal orelse return; tty.writeAll(buf) catch {