mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 15:13:08 +00:00
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:
parent
5418efa1e5
commit
94b0d0e802
@ -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,
|
||||
' ',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user