diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index ecef04c600..07f9077844 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -312,16 +312,10 @@ fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: any error.NoSpaceLeft => { self.columns_written += self.output_buffer.len - end.*; end.* = self.output_buffer.len; + const suffix = "... "; + std.mem.copy(u8, self.output_buffer[self.output_buffer.len - suffix.len ..], suffix); }, } - const bytes_needed_for_esc_codes_at_end: u8 = if (self.is_windows_terminal) 0 else 11; - const max_end = self.output_buffer.len - bytes_needed_for_esc_codes_at_end; - if (end.* > max_end) { - const suffix = "... "; - self.columns_written = self.columns_written - (end.* - max_end) + suffix.len; - std.mem.copy(u8, self.output_buffer[max_end..], suffix); - end.* = max_end + suffix.len; - } } test "basic functionality" { @@ -335,6 +329,8 @@ test "basic functionality" { const root_node = progress.start("", 100); defer root_node.end(); + const speed_factor = std.time.ns_per_ms; + const sub_task_names = [_][]const u8{ "reticulating splines", "adjusting shoes", @@ -350,24 +346,24 @@ test "basic functionality" { next_sub_task = (next_sub_task + 1) % sub_task_names.len; node.completeOne(); - std.time.sleep(5 * std.time.ns_per_ms); + std.time.sleep(5 * speed_factor); node.completeOne(); node.completeOne(); - std.time.sleep(5 * std.time.ns_per_ms); + std.time.sleep(5 * speed_factor); node.completeOne(); node.completeOne(); - std.time.sleep(5 * std.time.ns_per_ms); + std.time.sleep(5 * speed_factor); node.end(); - std.time.sleep(5 * std.time.ns_per_ms); + std.time.sleep(5 * speed_factor); } { var node = root_node.start("this is a really long name designed to activate the truncation code. let's find out if it works", 0); node.activate(); - std.time.sleep(10 * std.time.ns_per_ms); + std.time.sleep(10 * speed_factor); progress.refresh(); - std.time.sleep(10 * std.time.ns_per_ms); + std.time.sleep(10 * speed_factor); node.end(); } }