From 0ebfacb677aeb32ba749c738493993af997c0485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Tue, 21 May 2024 14:32:51 +0800 Subject: [PATCH] fix: inconsistent tab width in unassociated text files (#1068) --- README.md | 30 ++++++++++++------------- yazi-plugin/src/external/highlighter.rs | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bb3fc801..9b446df0 100644 --- a/README.md +++ b/README.md @@ -38,21 +38,21 @@ 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 | -| WezTerm | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| Mintty (Git Bash) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| foot | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | -| Ghostty | [Kitty old protocol](https://github.com/sxyazi/yazi/blob/main/yazi-adaptor/src/kitty_old.rs) | ✅ Built-in | -| Black Box | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | -| 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 | +| 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 | +| WezTerm | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| Mintty (Git Bash) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| foot | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | +| Ghostty | [Kitty old protocol](https://github.com/sxyazi/yazi/blob/main/yazi-adaptor/src/kitty_old.rs) | ✅ Built-in | +| Black Box | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | +| 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++](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. diff --git a/yazi-plugin/src/external/highlighter.rs b/yazi-plugin/src/external/highlighter.rs index b4fd6b39..0e681b96 100644 --- a/yazi-plugin/src/external/highlighter.rs +++ b/yazi-plugin/src/external/highlighter.rs @@ -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 }