mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-23 14:58:49 +01:00
Improve logic for SGR sequence passthrough
This commit is contained in:
parent
34811b8161
commit
0ddd388a29
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user