@@ -472,6 +472,14 @@ fn updateThreadRun() void {
472
472
}
473
473
}
474
474
475
+ fn windowsApiWriteMarker () void {
476
+ // Write the marker that we will use to find the beginning of the progress when clearing.
477
+ // Note: This doesn't have to use WriteConsoleW, but doing so avoids dealing with the code page.
478
+ var num_chars_written : windows.DWORD = undefined ;
479
+ const handle = global_progress .terminal .handle ;
480
+ _ = windows .kernel32 .WriteConsoleW (handle , &[_ ]u16 {windows_api_start_marker }, 1 , & num_chars_written , null );
481
+ }
482
+
475
483
fn windowsApiUpdateThreadRun () void {
476
484
var serialized_buffer : Serialized.Buffer = undefined ;
477
485
@@ -483,6 +491,7 @@ fn windowsApiUpdateThreadRun() void {
483
491
const buffer = computeRedraw (& serialized_buffer );
484
492
if (stderr_mutex .tryLock ()) {
485
493
defer stderr_mutex .unlock ();
494
+ windowsApiWriteMarker ();
486
495
write (buffer ) catch return ;
487
496
}
488
497
}
@@ -502,6 +511,7 @@ fn windowsApiUpdateThreadRun() void {
502
511
if (stderr_mutex .tryLock ()) {
503
512
defer stderr_mutex .unlock ();
504
513
clearWrittenWindowsApi () catch return ;
514
+ windowsApiWriteMarker ();
505
515
write (buffer ) catch return ;
506
516
}
507
517
}
@@ -1048,8 +1058,10 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) []u8 {
1048
1058
var i : usize = 0 ;
1049
1059
const buf = global_progress .draw_buffer ;
1050
1060
1051
- buf [i .. ][0.. start_sync .len ].* = start_sync .* ;
1052
- i += start_sync .len ;
1061
+ if (global_progress .terminal_mode == .ansi_escape_codes ) {
1062
+ buf [i .. ][0.. start_sync .len ].* = start_sync .* ;
1063
+ i += start_sync .len ;
1064
+ }
1053
1065
1054
1066
switch (global_progress .terminal_mode ) {
1055
1067
.off = > unreachable ,
@@ -1061,8 +1073,10 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) []u8 {
1061
1073
const root_node_index : Node.Index = @enumFromInt (0 );
1062
1074
i = computeNode (buf , i , serialized , children , root_node_index );
1063
1075
1064
- buf [i .. ][0.. finish_sync .len ].* = finish_sync .* ;
1065
- i += finish_sync .len ;
1076
+ if (global_progress .terminal_mode == .ansi_escape_codes ) {
1077
+ buf [i .. ][0.. finish_sync .len ].* = finish_sync .* ;
1078
+ i += finish_sync .len ;
1079
+ }
1066
1080
1067
1081
return buf [0.. i ];
1068
1082
}
0 commit comments