Skip to content

Commit

Permalink
Fix bold, intense color on Windows 10 console.
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.

This is for rust-lang/rust#49322.
  • Loading branch information
ehuss committed Mar 26, 2018
1 parent d7c9323 commit cc4ea77
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 cc4ea77

Please sign in to comment.