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.
This commit is contained in:
Ryan Liptak 2023-07-01 20:41:12 -07:00 committed by Andrew Kelley
parent 9e0ac4449a
commit 689f3163af

View File

@ -20,6 +20,8 @@ pub fn detectConfig(file: File) Config {
if (force_color == false) return .no_color; if (force_color == false) return .no_color;
if (file.supportsAnsiEscapeCodes()) return .escape_codes;
if (native_os == .windows and file.isTty()) { if (native_os == .windows and file.isTty()) {
var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) { if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) {
@ -31,11 +33,7 @@ pub fn detectConfig(file: File) Config {
} }; } };
} }
if (force_color == true or file.supportsAnsiEscapeCodes()) { return if (force_color == true) .escape_codes else .no_color;
return .escape_codes;
}
return .no_color;
} }
pub const Color = enum { pub const Color = enum {