Fix unwanted ANSI Reset Sequence
@@ -35,11 +35,12 @@ pub fn enable_ansi() {
}
fn style(s: &str, colorspec: ColorSpec) -> impl fmt::Display {
+ if !use_color() {
+ return String::from(s);
+ }
let mut v = Vec::new();
let mut ansi_writer = Ansi::new(&mut v);
- if use_color() {
ansi_writer.set_color(&colorspec).unwrap();
- }
ansi_writer.write_all(s.as_bytes()).unwrap();
ansi_writer.reset().unwrap();
String::from_utf8_lossy(&v).into_owned()
