fix: inconsistent tab width in unassociated text files (#1068)

This commit is contained in:
三咲雅 · Misaki Masa 2024-05-21 14:32:51 +08:00 committed by sxyazi
parent 7177317465
commit 0ebfacb677
No known key found for this signature in database
2 changed files with 17 additions and 16 deletions

View File

@ -39,7 +39,7 @@ https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265
## Image Preview
| Platform | Protocol | Support |
| ----------------- | ----------------------------------------------------------------------------------------------------- | --------------------- |
| ----------------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| kitty | [Kitty unicode placeholders](https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders) | ✅ Built-in |
| Konsole | [Kitty old protocol](https://github.com/sxyazi/yazi/blob/main/yazi-adaptor/src/kitty_old.rs) | ✅ Built-in |
| iTerm2 | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
@ -51,8 +51,8 @@ https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265
| VSCode | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
| Tabby | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
| Hyper | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
| X11 / Wayland | Window system protocol | ☑️ Überzug++ required |
| Fallback | [Chafa](https://hpjansson.org/chafa/) | ☑️ Überzug++ required |
| X11 / Wayland | Window system protocol | ☑️ [Überzug++](https://github.com/jstkdng/ueberzugpp) required |
| Fallback | [ASCII art (Unicode block)](https://en.wikipedia.org/wiki/ASCII_art) | ☑️ [Chafa](https://hpjansson.org/chafa/) required |
See https://yazi-rs.github.io/docs/image-preview for details.

View File

@ -97,7 +97,8 @@ impl Highlighter {
}
if plain {
Ok(Text::from(after.join("")))
let indent = " ".repeat(PREVIEW.tab_size as usize);
Ok(Text::from(after.join("").replace('\t', &indent)))
} else {
Self::highlight_with(before, after, syntax.unwrap()).await
}