2
0
mirror of https://github.com/sharkdp/bat synced 2024-11-16 21:25:56 +00:00

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 {
// ANSI escape passthrough.
(text, true) => {
if text.chars().last().unwrap() == 'm' {
self.ansi_prefix_sgr.push_str(text);
if text.chars().last().map_or(false, |c| c == 'm') {
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 {
ansi_prefix.push_str(text);
}