authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-06-02 04:06:49-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-02 13:04:25-04:00
log2cf8e73781b81f38c50a40b42cad49242ef7c98b
treeaf8a1ad570f771d7f7ae9723eeac28d9540f5c71
parent5e1ccd96e5dcd2ed2d38d3260edcdd68b4b8da9d

Progress: Emit \r\n on Windows, include new line bytes in line_upper_bound_len

The \r\n is necessary to get the progress tree to work properly in the old console when ENABLE_VIRTUAL_TERMINAL_PROCESSING and DISABLE_NEWLINE_AUTO_RETURN are set. The line_upper_bound_len fix addresses part of #20161

1 files changed, 10 insertions(+), 1 deletions(-)

lib/std/Progress.zig+10-1
......@@ -1133,8 +1133,10 @@ fn computePrefix(
11331133 return i;
11341134}
11351135
1136// \r\n on Windows, \n otherwise.
1137const nl_len = if (is_windows) 2 else 1;
11361138const 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;
1139 "[4294967296/4294967296] ".len + Node.max_name_len + nl_len + (1 + up_one_line.len) + finish_sync.len;
11381140
11391141fn computeNode(
11401142 buf: []u8,
......@@ -1183,6 +1185,13 @@ fn computeNode(
11831185 }
11841186
11851187 i = @min(global_progress.cols + start_i, i);
1188 if (is_windows) {
1189 // \r\n on Windows is necessary for the old console with the
1190 // ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN
1191 // console modes set to behave properly.
1192 buf[i] = '\r';
1193 i += 1;
1194 }
11861195 buf[i] = '\n';
11871196 i += 1;
11881197 nl_n += 1;