# std.debug.TTY: Fix colors not resetting on Windows · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/88d927a511922efd82c4ec862c8e2aa83df84391)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 88d927a511922efd82c4ec862c8e2aa83df84391

Requested commit: 88d927a511922efd82c4ec862c8e2aa83df84391

Commit: 88d927a511922efd82c4ec862c8e2aa83df84391

Tree: 16449de5465989e1e3f8ae7894b5544cd9491109

Author: Ryan Liptak

Committer: Andrew Kelley

## Message

```
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)

```

## Parents

- [83e0e23f8aa2d90495bbf9c3649aa68f7c55c926](https://git.cafe/gitcafe/zig/commit/83e0e23f8aa2d90495bbf9c3649aa68f7c55c926?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/88d927a511922efd82c4ec862c8e2aa83df84391?format=markdown)
