aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
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 'src')
-rw-r--r--src/main.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig
index a7d4dc6f03..f602470a45 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -3431,7 +3431,7 @@ fn updateModule(gpa: Allocator, comp: *Compilation, hook: AfterUpdateHook) !void
if (errors.list.len != 0) {
const ttyconf: std.debug.TTY.Config = switch (comp.color) {
- .auto => std.debug.detectTTYConfig(),
+ .auto => std.debug.detectTTYConfig(std.io.getStdErr()),
.on => .escape_codes,
.off => .no_color,
};
@@ -4252,7 +4252,7 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
try Compilation.AllErrors.addZir(arena_instance.allocator(), &errors, &file);
const ttyconf: std.debug.TTY.Config = switch (color) {
- .auto => std.debug.detectTTYConfig(),
+ .auto => std.debug.detectTTYConfig(std.io.getStdErr()),
.on => .escape_codes,
.off => .no_color,
};
@@ -4465,7 +4465,7 @@ fn fmtPathFile(
try Compilation.AllErrors.addZir(arena_instance.allocator(), &errors, &file);
const ttyconf: std.debug.TTY.Config = switch (fmt.color) {
- .auto => std.debug.detectTTYConfig(),
+ .auto => std.debug.detectTTYConfig(std.io.getStdErr()),
.on => .escape_codes,
.off => .no_color,
};
@@ -4586,7 +4586,7 @@ fn printErrsMsgToStdErr(
};
const ttyconf: std.debug.TTY.Config = switch (color) {
- .auto => std.debug.detectTTYConfig(),
+ .auto => std.debug.detectTTYConfig(std.io.getStdErr()),
.on => .escape_codes,
.off => .no_color,
};
@@ -5176,7 +5176,7 @@ pub fn cmdAstCheck(
var errors = std.ArrayList(Compilation.AllErrors.Message).init(arena);
try Compilation.AllErrors.addZir(arena, &errors, &file);
const ttyconf: std.debug.TTY.Config = switch (color) {
- .auto => std.debug.detectTTYConfig(),
+ .auto => std.debug.detectTTYConfig(std.io.getStdErr()),
.on => .escape_codes,
.off => .no_color,
};
@@ -5301,7 +5301,7 @@ pub fn cmdChangelist(
if (file.zir.hasCompileErrors()) {
var errors = std.ArrayList(Compilation.AllErrors.Message).init(arena);
try Compilation.AllErrors.addZir(arena, &errors, &file);
- const ttyconf = std.debug.detectTTYConfig();
+ const ttyconf = std.debug.detectTTYConfig(std.io.getStdErr());
for (errors.items) |full_err_msg| {
full_err_msg.renderToStdErr(ttyconf);
}
@@ -5340,7 +5340,7 @@ pub fn cmdChangelist(
if (file.zir.hasCompileErrors()) {
var errors = std.ArrayList(Compilation.AllErrors.Message).init(arena);
try Compilation.AllErrors.addZir(arena, &errors, &file);
- const ttyconf = std.debug.detectTTYConfig();
+ const ttyconf = std.debug.detectTTYConfig(std.io.getStdErr());
for (errors.items) |full_err_msg| {
full_err_msg.renderToStdErr(ttyconf);
}