Improve logic for SGR sequence passthrough

This commit is contained in:
eth-p 2018-07-05 14:30:06 -07:00 committed by David Peter
parent 34811b8161
commit 0ddd388a29

View File

@ -164,9 +164,13 @@ impl<'a> Printer<'a> {
match chunk { match chunk {
// ANSI escape passthrough. // ANSI escape passthrough.
(text, true) => { (text, true) => {
if text.chars().last().unwrap() == 'm' { if text.chars().last().map_or(false, |c| c == 'm') {
self.ansi_prefix_sgr.push_str(text);
ansi_prefix.push_str(text); ansi_prefix.push_str(text);
if text == "\x1B[0m" {
self.ansi_prefix_sgr = "\x1B[0m".to_owned();
} else {
self.ansi_prefix_sgr.push_str(text);
}
} else { } else {
ansi_prefix.push_str(text); ansi_prefix.push_str(text);
} }