mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
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.
This commit is contained in:
parent
e45329a689
commit
9e78bdcf6e
1 changed files with 2 additions and 3 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue