@@ -1106,6 +1106,7 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) struct { []u8, usize } {
1106
1106
fn computePrefix (
1107
1107
buf : []u8 ,
1108
1108
start_i : usize ,
1109
+ nl_n : usize ,
1109
1110
serialized : Serialized ,
1110
1111
children : []const Children ,
1111
1112
node_index : Node.Index ,
@@ -1118,23 +1119,27 @@ fn computePrefix(
1118
1119
{
1119
1120
return i ;
1120
1121
}
1121
- i = computePrefix (buf , i , serialized , children , parent_index );
1122
+ i = computePrefix (buf , i , nl_n , serialized , children , parent_index );
1122
1123
if (children [@intFromEnum (parent_index )].sibling == .none ) {
1123
1124
const prefix = " " ;
1124
- const upper_bound_len = prefix .len + line_upper_bound_len ;
1125
+ const upper_bound_len = prefix .len + lineUpperBoundLen ( nl_n ) ;
1125
1126
if (i + upper_bound_len > buf .len ) return buf .len ;
1126
1127
buf [i .. ][0.. prefix .len ].* = prefix .* ;
1127
1128
i += prefix .len ;
1128
1129
} else {
1129
- const upper_bound_len = comptime ( TreeSymbol .line .maxByteLen () + line_upper_bound_len );
1130
+ const upper_bound_len = TreeSymbol .line .maxByteLen () + lineUpperBoundLen ( nl_n );
1130
1131
if (i + upper_bound_len > buf .len ) return buf .len ;
1131
1132
i = appendTreeSymbol (.line , buf , i );
1132
1133
}
1133
1134
return i ;
1134
1135
}
1135
1136
1136
- const line_upper_bound_len = @max (TreeSymbol .tee .maxByteLen (), TreeSymbol .langle .maxByteLen ()) +
1137
- "[4294967296/4294967296] " .len + Node .max_name_len + (1 + up_one_line .len ) + finish_sync .len ;
1137
+ fn lineUpperBoundLen (nl_n : usize ) usize {
1138
+ return @max (TreeSymbol .tee .maxByteLen (), TreeSymbol .langle .maxByteLen ()) +
1139
+ "[4294967296/4294967296] " .len + Node .max_name_len + 1 +
1140
+ (1 + (nl_n + 1 ) * up_one_line .len ) +
1141
+ finish_sync .len ;
1142
+ }
1138
1143
1139
1144
fn computeNode (
1140
1145
buf : []u8 ,
@@ -1147,9 +1152,9 @@ fn computeNode(
1147
1152
var i = start_i ;
1148
1153
var nl_n = start_nl_n ;
1149
1154
1150
- i = computePrefix (buf , i , serialized , children , node_index );
1155
+ i = computePrefix (buf , i , nl_n , serialized , children , node_index );
1151
1156
1152
- if (i + line_upper_bound_len > buf .len )
1157
+ if (i + lineUpperBoundLen ( nl_n ) > buf .len )
1153
1158
return .{ start_i , start_nl_n };
1154
1159
1155
1160
const storage = & serialized .storage [@intFromEnum (node_index )];
0 commit comments