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:
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