| ... | ... | @@ -875,15 +875,23 @@ fn computePrefix( |
| 875 | 875 | if (serialized.parents[@intFromEnum(parent_index)] == .none) return i; |
| 876 | 876 | i = computePrefix(buf, i, serialized, children, parent_index); |
| 877 | 877 | if (children[@intFromEnum(parent_index)].sibling == .none) { |
| 878 | | buf[i..][0..3].* = " ".*; |
| 879 | | i += 3; |
| 878 | const prefix = " "; |
| 879 | const upper_bound_len = prefix.len + line_upper_bound_len; |
| 880 | if (i + upper_bound_len > buf.len) return buf.len; |
| 881 | buf[i..][0..prefix.len].* = prefix.*; |
| 882 | i += prefix.len; |
| 880 | 883 | } else { |
| 884 | const upper_bound_len = tree_line.len + line_upper_bound_len; |
| 885 | if (i + upper_bound_len > buf.len) return buf.len; |
| 881 | 886 | buf[i..][0..tree_line.len].* = tree_line.*; |
| 882 | 887 | i += tree_line.len; |
| 883 | 888 | } |
| 884 | 889 | return i; |
| 885 | 890 | } |
| 886 | 891 | |
| 892 | const line_upper_bound_len = @max(tree_tee.len, tree_langle.len) + "[4294967296/4294967296] ".len + |
| 893 | Node.max_name_len + finish_sync.len; |
| 894 | |
| 887 | 895 | fn computeNode( |
| 888 | 896 | buf: []u8, |
| 889 | 897 | start_i: usize, |
| ... | ... | @@ -894,6 +902,9 @@ fn computeNode( |
| 894 | 902 | var i = start_i; |
| 895 | 903 | i = computePrefix(buf, i, serialized, children, node_index); |
| 896 | 904 | |
| 905 | if (i + line_upper_bound_len > buf.len) |
| 906 | return start_i; |
| 907 | |
| 897 | 908 | const storage = &serialized.storage[@intFromEnum(node_index)]; |
| 898 | 909 | const estimated_total = storage.estimated_total_count; |
| 899 | 910 | const completed_items = storage.completed_count; |
| ... | ... | @@ -910,19 +921,19 @@ fn computeNode( |
| 910 | 921 | } |
| 911 | 922 | } |
| 912 | 923 | |
| 913 | | if (name.len != 0 or estimated_total > 0) { |
| 914 | | if (estimated_total > 0) { |
| 915 | | i += (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total }) catch &.{}).len; |
| 916 | | } else if (completed_items != 0) { |
| 917 | | i += (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items}) catch &.{}).len; |
| 918 | | } |
| 919 | | if (name.len != 0) { |
| 920 | | i += (std.fmt.bufPrint(buf[i..], "{s}", .{name}) catch &.{}).len; |
| 921 | | } |
| 922 | | } |
| 923 | | |
| 924 | 924 | const is_empty_root = @intFromEnum(node_index) == 0 and serialized.storage[0].name[0] == 0; |
| 925 | 925 | if (!is_empty_root) { |
| 926 | if (name.len != 0 or estimated_total > 0) { |
| 927 | if (estimated_total > 0) { |
| 928 | i += (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total }) catch &.{}).len; |
| 929 | } else if (completed_items != 0) { |
| 930 | i += (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items}) catch &.{}).len; |
| 931 | } |
| 932 | if (name.len != 0) { |
| 933 | i += (std.fmt.bufPrint(buf[i..], "{s}", .{name}) catch &.{}).len; |
| 934 | } |
| 935 | } |
| 936 | |
| 926 | 937 | i = @min(global_progress.cols + start_i, i); |
| 927 | 938 | buf[i] = '\n'; |
| 928 | 939 | i += 1; |