Skip to content

Commit cc4ea77

Browse files
committed
Fix bold, intense color on Windows 10 console.
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.
1 parent d7c9323 commit cc4ea77

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

termcolor/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -971,18 +971,18 @@ impl<W: io::Write> WriteColor for Ansi<W> {
971971

972972
fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> {
973973
self.reset()?;
974-
if let Some(ref c) = spec.fg_color {
975-
self.write_color(true, c, spec.intense)?;
976-
}
977-
if let Some(ref c) = spec.bg_color {
978-
self.write_color(false, c, spec.intense)?;
979-
}
980974
if spec.bold {
981975
self.write_str("\x1B[1m")?;
982976
}
983977
if spec.underline {
984978
self.write_str("\x1B[4m")?;
985979
}
980+
if let Some(ref c) = spec.fg_color {
981+
self.write_color(true, c, spec.intense)?;
982+
}
983+
if let Some(ref c) = spec.bg_color {
984+
self.write_color(false, c, spec.intense)?;
985+
}
986986
Ok(())
987987
}
988988

0 commit comments

Comments
 (0)