authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-07-01 20:41:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-02 00:07:24-07:00
log689f3163af48fd6e0c08bb76fadfb711db30c97c
treedd3048141b062c1fd38df60020116e5fa7a0a053
parent9e0ac4449a18677ba695f7a75342cbdb049aad52

Fix `TTY.detectConfig` regression on windows

e05412669c8dde1230612de5af64fbc3fb0bc17e inadvertently changed the logic on Windows and made it so that supportsAnsiEscapeCodes was never checked. This fixes that regression while keeping the logic intact for other platforms.

1 files changed, 3 insertions(+), 5 deletions(-)

lib/std/io/tty.zig+3-5
...@@ -20,6 +20,8 @@ pub fn detectConfig(file: File) Config {...@@ -20,6 +20,8 @@ pub fn detectConfig(file: File) Config {
2020
21 if (force_color == false) return .no_color;21 if (force_color == false) return .no_color;
2222
23 if (file.supportsAnsiEscapeCodes()) return .escape_codes;
24
23 if (native_os == .windows and file.isTty()) {25 if (native_os == .windows and file.isTty()) {
24 var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;26 var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
25 if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) {27 if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) {
...@@ -31,11 +33,7 @@ pub fn detectConfig(file: File) Config {...@@ -31,11 +33,7 @@ pub fn detectConfig(file: File) Config {
31 } };33 } };
32 }34 }
3335
34 if (force_color == true or file.supportsAnsiEscapeCodes()) {36 return if (force_color == true) .escape_codes else .no_color;
35 return .escape_codes;
36 }
37
38 return .no_color;
39}37}
4038
41pub const Color = enum {39pub const Color = enum {