From 0650affb76e61dbe76223f11661a11a5019c3255 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: Sat, 6 Apr 2024 08:53:48 +0800 Subject: [PATCH] fix: CJK text rendering issue where the input popup component overlaps with images (#879) --- yazi-fm/src/app/commands/render.rs | 12 +++++++----- yazi-plugin/src/elements/clear.rs | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/yazi-fm/src/app/commands/render.rs b/yazi-fm/src/app/commands/render.rs index df5808d0..e62f50b4 100644 --- a/yazi-fm/src/app/commands/render.rs +++ b/yazi-fm/src/app/commands/render.rs @@ -1,6 +1,6 @@ use std::{io::{stderr, BufWriter}, sync::atomic::Ordering}; -use ratatui::{backend::{Backend, CrosstermBackend}, CompletedFrame}; +use ratatui::{backend::{Backend, CrosstermBackend}, buffer::Buffer, CompletedFrame}; use yazi_plugin::elements::COLLISION; use crate::{app::App, lives::Lives, root::Root}; @@ -61,16 +61,18 @@ impl App { #[inline] fn patch(frame: CompletedFrame, cursor: Option<(u16, u16)>) { - let mut patches = vec![]; - for y in frame.area.top()..frame.area.bottom() { - for x in frame.area.left()..frame.area.right() { + let mut new = Buffer::empty(frame.area); + for y in new.area.top()..new.area.bottom() { + for x in new.area.left()..new.area.right() { let cell = frame.buffer.get(x, y); if cell.skip { - patches.push((x, y, cell)); + *new.get_mut(x, y) = cell.clone(); } + new.get_mut(x, y).set_skip(!cell.skip); } } + let patches = frame.buffer.diff(&new); let mut backend = CrosstermBackend::new(BufWriter::new(stderr().lock())); backend.draw(patches.into_iter()).ok(); if let Some((x, y)) = cursor { diff --git a/yazi-plugin/src/elements/clear.rs b/yazi-plugin/src/elements/clear.rs index dfd0e2f4..0c6f4c7d 100644 --- a/yazi-plugin/src/elements/clear.rs +++ b/yazi-plugin/src/elements/clear.rs @@ -37,8 +37,8 @@ impl ratatui::widgets::Widget for Clear { ADAPTOR.image_erase(r).ok(); COLLISION.store(true, Ordering::Relaxed); - for y in area.top()..area.bottom() { - for x in area.left()..area.right() { + for y in r.top()..r.bottom() { + for x in r.left()..r.right() { buf.get_mut(x, y).set_skip(true); } }