You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I want to use style::force_color_output to disable ANSI escape codes entirely, for the case the output stream is redirected to a file.
The colors are disabled, but not attributes such as bold. As a result, some ANSI escape codes are leaked into the file.
To Reproduce
Consider this function
pubfnprint_diagnostic(err:&tc::Error,indent:u32) -> io::Result<()>{let span = err.span();let disabled = if !io::stderr().is_terminal(){// check NO_COLOR status to reinitialize the correct value afterwardslet disabled = Colored::ansi_color_disabled();
style::force_color_output(false);Some(disabled)}else{None};eprintln!("{}{}"," ".repeat((indent + span.0)as _),"^".repeat((span.1 - span.0)as _).red().bold());eprintln!("{}: {}","error".red().bold(), err.to_string().bold());ifletSome(disabled) = disabled {Colored::set_ansi_color_disabled(disabled);}
io::stderr().flush()}
OS
e.g. Windows
Terminal/Console
Windows Terminal, VsCode integrated terminal
The text was updated successfully, but these errors were encountered:
rtbo
added a commit
to rtbo/crossterm
that referenced
this issue
Aug 28, 2024
Describe the bug
I want to use
style::force_color_output
to disable ANSI escape codes entirely, for the case the output stream is redirected to a file.The colors are disabled, but not attributes such as
bold
. As a result, some ANSI escape codes are leaked into the file.To Reproduce
Consider this function
OS
Terminal/Console
The text was updated successfully, but these errors were encountered: