aboutsummaryrefslogtreecommitdiff
path: root/lib/std/testing.zig
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2022-12-14 20:01:11 -0800
committerAndrew Kelley <andrew@ziglang.org>2022-12-15 03:49:26 -0500
commit88d927a511922efd82c4ec862c8e2aa83df84391 (patch)
tree16449de5465989e1e3f8ae7894b5544cd9491109 /lib/std/testing.zig
parent83e0e23f8aa2d90495bbf9c3649aa68f7c55c926 (diff)
downloadzig-88d927a511922efd82c4ec862c8e2aa83df84391.tar.gz
zig-88d927a511922efd82c4ec862c8e2aa83df84391.zip
std.debug.TTY: Fix colors not resetting on Windows
This fixes a regression introduced in #12298 where colors would never reset in a Windows console because the attributes would be queried on every `setColor` call, and then try to 'reset' the attributes to what it just queried (i.e. it was essentially doing a complicated no-op on .Reset). This fixes the problem while (I think) keeping with the spirit of the changes in #12298--that is, `TTY.Config` is not specifically tied to stderr like it was before #12298. To that end, detectTTYConfig now takes a `File` and that's what gets used to query the initial attributes to reset to. (for context, before #12298, the first `setColor` call is where the reset attributes would get queried and it would always use stderr to do it)
Diffstat (limited to 'lib/std/testing.zig')
-rw-r--r--lib/std/testing.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
index af0074a549..72f3ba2d9e 100644
--- a/lib/std/testing.zig
+++ b/lib/std/testing.zig
@@ -312,7 +312,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const
const actual_window = actual[window_start..@min(actual.len, window_start + max_window_size)];
const actual_truncated = window_start + actual_window.len < actual.len;
- const ttyconf = std.debug.detectTTYConfig();
+ const ttyconf = std.debug.detectTTYConfig(std.io.getStdErr());
var differ = if (T == u8) BytesDiffer{
.expected = expected_window,
.actual = actual_window,