std.progress: handle error from FillConsoleOutputAttribute

I observed this returning an error. Fall back to not doing
terminal stuff if an error occurs here.

See #5244
This commit is contained in:
Andrew Kelley 2020-05-01 15:13:55 -04:00
parent 5418efa1e5
commit 94b0d0e802

View File

@ -145,7 +145,7 @@ pub const Progress = struct {
if (self.supports_ansi_escape_codes) {
end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;
end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
} else if (std.builtin.os.tag == .windows) {
} else if (std.builtin.os.tag == .windows) winapi: {
var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE)
unreachable;
@ -167,7 +167,11 @@ pub const Progress = struct {
fill_chars,
cursor_pos,
&written,
) != windows.TRUE) unreachable;
) != windows.TRUE) {
// Stop trying to write to this file.
self.terminal = null;
break :winapi;
}
if (windows.kernel32.FillConsoleOutputCharacterA(
file.handle,
' ',