Skip to content

Commit

Permalink
termcolor: fix bold + intense colors in Win 10
Browse files Browse the repository at this point in the history
There is an issue with the Windows 10 console where if you issue the bold
escape sequence after one of the extended foreground colors, it overrides the
color.  This happens in termcolor if you have bold, intense, and color set.
The workaround is to issue the bold sequence before the color.

Fixes rust-lang/rust#49322
  • Loading branch information
ehuss authored and BurntSushi committed Mar 26, 2018
1 parent d7c9323 commit 07713fb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions termcolor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,18 +971,18 @@ impl<W: io::Write> WriteColor for Ansi<W> {

fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> {
self.reset()?;
if let Some(ref c) = spec.fg_color {
self.write_color(true, c, spec.intense)?;
}
if let Some(ref c) = spec.bg_color {
self.write_color(false, c, spec.intense)?;
}
if spec.bold {
self.write_str("\x1B[1m")?;
}
if spec.underline {
self.write_str("\x1B[4m")?;
}
if let Some(ref c) = spec.fg_color {
self.write_color(true, c, spec.intense)?;
}
if let Some(ref c) = spec.bg_color {
self.write_color(false, c, spec.intense)?;
}
Ok(())
}

Expand Down

0 comments on commit 07713fb

Please sign in to comment.