fix: preview ascii escape image in yazi#1391

This commit is contained in:
Xerxes-2 2024-08-02 15:30:20 +10:00
parent 9d1fab84ef
commit 9822fccc3b
No known key found for this signature in database
GPG key ID: A6C508165D76B601

View file

@ -97,8 +97,14 @@ impl Highlighter {
} }
if plain { if plain {
let indent = " ".repeat(PREVIEW.tab_size as usize); if after.iter().any(|l| l.contains('\x1b')) {
Ok(Text::from(after.join("").replace('\t', &indent))) let bytes = after.join("").bytes().collect::<Vec<_>>();
use ansi_to_tui::IntoText;
bytes.into_text().map_err(|e| PeekError::Unexpected(e.to_string()))
} else {
let indent = " ".repeat(PREVIEW.tab_size as usize);
Ok(Text::from(after.join("").replace('\t', &indent)))
}
} else { } else {
Self::highlight_with(before, after, syntax.unwrap()).await Self::highlight_with(before, after, syntax.unwrap()).await
} }