mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-23 23:08:54 +01:00
Replace iterator with string starts_with and ends_with
This commit is contained in:
parent
cc8186103b
commit
2b9d25df05
@ -367,10 +367,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
match chunk {
|
match chunk {
|
||||||
// ANSI escape passthrough.
|
// ANSI escape passthrough.
|
||||||
(text, true) => {
|
(text, true) => {
|
||||||
let is_ansi_csi =
|
let is_ansi_csi = text.starts_with("\x1B[");
|
||||||
text.chars().skip(1).nth(0).map_or(false, |c| c == '[');
|
|
||||||
|
|
||||||
if is_ansi_csi && text.chars().last().map_or(false, |c| c == 'm') {
|
if is_ansi_csi && text.ends_with('m') {
|
||||||
// It's an ANSI SGR sequence.
|
// It's an ANSI SGR sequence.
|
||||||
// We should be mostly safe to just append these together.
|
// We should be mostly safe to just append these together.
|
||||||
ansi_prefix.push_str(text);
|
ansi_prefix.push_str(text);
|
||||||
|
Loading…
Reference in New Issue
Block a user