Skip to content

Conversation

@trulede
Copy link
Contributor

@trulede trulede commented Dec 12, 2025

Enable ANSI escape code handling on windows consoles.

fixes #2076

This sets the windows terminal so that it handles ANSI codes (esp color). Under some circumstances (not known) a windows console may be in a mode where it does not process ANSI codes, as a result task output (color=true or false) will show escape sequences:

C:\Users\trule\Desktop>task
←[31mtask: No Taskfile found at ""
←[0m

This PR pushes the terminal into the correct mode (ENABLE_VIRTUAL_TERMINAL_PROCESSING).

@trulede trulede mentioned this pull request Dec 12, 2025
@trulede trulede marked this pull request as ready for review December 15, 2025 22:23
@andreynering andreynering added the os: windows Issues that affect users on Windows. label Jan 18, 2026
@andreynering
Copy link
Member

Hey @trulede.

Were you able to reproduce the problem? If so, how? Which terminal app?

@trulede
Copy link
Contributor Author

trulede commented Jan 18, 2026

@andreynering I modified the code in the PR to force the condition (clearing the flag), proving the reported behaviour (and thus the solution). But would it solve the issue for the originator? Probably.

Still, its not a Task issue. Something in the terminal is wrong of the originators pc. They have indicated as much.

Although I don't think there is much risk with this PR, in case the console is not a terminal, the call to GetConsoleMode() will err and nothing else will happen. At least someone else should verify the PR - I suggest forcing the condition, my efforts to reproduce the broken console took a long time and were not effective.

Almost certainly, something else is the cause.

There could be a task user who does not want this flag set? We could restrict it further, for instance, only setting it if color is enabled. Or make the change, and wait for feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

os: windows Issues that affect users on Windows.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coloring on windows.

2 participants