From 9e78bdcf6e2430a742c9314edbcb6da3559f94ab Mon Sep 17 00:00:00 2001 From: June Kim Date: Sat, 9 May 2026 10:11:13 -0700 Subject: [PATCH] fix: use UnicodeWidthStr to handle VS16/ZWJ grapheme clusters correctly UnicodeWidthChar on the first char misses grapheme clusters where the base char is narrow but the full grapheme (with variation selectors) renders wide. UnicodeWidthStr on the whole symbol string handles all cases: CJK, emoji with VS16, ZWJ sequences. --- yazi-widgets/src/clear.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/yazi-widgets/src/clear.rs b/yazi-widgets/src/clear.rs index cc2920d3..ce7c1194 100644 --- a/yazi-widgets/src/clear.rs +++ b/yazi-widgets/src/clear.rs @@ -1,7 +1,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget}; -use unicode_width::UnicodeWidthChar; +use unicode_width::UnicodeWidthStr; use yazi_adapter::ADAPTOR; pub static COLLISION: AtomicBool = AtomicBool::new(false); @@ -24,8 +24,7 @@ impl Widget for Clear { if area.x > buf.area.x { let left = area.x - 1; for y in area.top()..area.bottom() { - let ch = buf[(left, y)].symbol().chars().next(); - if ch.is_some_and(|c| c.width().unwrap_or(0) > 1) { + if buf[(left, y)].symbol().width() > 1 { buf[(left, y)].reset(); } }