From 3fa6b641f2d2d7d141d9854afae60dc925db1513 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sun, 22 Feb 2026 10:29:07 +0800 Subject: [PATCH] .. --- yazi-fm/src/app/render.rs | 41 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/yazi-fm/src/app/render.rs b/yazi-fm/src/app/render.rs index 0db64eef..b2292063 100644 --- a/yazi-fm/src/app/render.rs +++ b/yazi-fm/src/app/render.rs @@ -5,6 +5,7 @@ use crossterm::{cursor::{MoveTo, SetCursorStyle, Show}, execute, queue, terminal use ratatui::{CompletedFrame, backend::{Backend, CrosstermBackend}, buffer::Buffer, layout::Position}; use yazi_actor::{Ctx, lives::Lives}; use yazi_binding::runtime_scope; +use yazi_config::LAYOUT; use yazi_macro::{act, succ}; use yazi_plugin::LUA; use yazi_shared::{data::Data, event::NEED_RENDER}; @@ -26,13 +27,12 @@ impl App { let _guard = scopeguard::guard(self.core.cursor(), |c| Self::routine(false, c)); let collision = COLLISION.swap(false, Ordering::Relaxed); - let frame = term - .draw(|f| { - _ = Lives::scope(&self.core, || { - runtime_scope!(LUA, "root", Ok(f.render_widget(Root::new(&self.core), f.area()))) - }); - }) - .unwrap(); + let preview_rect = LAYOUT.get().preview; + let frame = term.draw(|f| { + _ = Lives::scope(&self.core, || { + runtime_scope!(LUA, "root", Ok(f.render_widget(Root::new(&self.core), f.area()))) + }); + })?; if COLLISION.load(Ordering::Relaxed) { Self::patch(frame); @@ -41,10 +41,11 @@ impl App { self.render_partially()?; } - // Reload preview if collision is resolved + let cx = &mut Ctx::active(&mut self.core, &mut self.term); if collision && !COLLISION.load(Ordering::Relaxed) { - let cx = &mut Ctx::active(&mut self.core, &mut self.term); - act!(mgr:peek, cx, true)?; + act!(mgr:peek, cx, true)?; // Reload preview if collision is resolved + } else if preview_rect != LAYOUT.get().preview { + act!(mgr:peek, cx)?; // Reload preview if layout changed } succ!(); } @@ -58,17 +59,15 @@ impl App { Self::routine(true, None); let _guard = scopeguard::guard(self.core.cursor(), |c| Self::routine(false, c)); - let frame = term - .draw_partial(|f| { - _ = Lives::scope(&self.core, || { - runtime_scope!(LUA, "root", { - f.render_widget(crate::tasks::Progress::new(&self.core), f.area()); - f.render_widget(crate::notify::Notify::new(&self.core), f.area()); - Ok(()) - }) - }); - }) - .unwrap(); + let frame = term.draw_partial(|f| { + _ = Lives::scope(&self.core, || { + runtime_scope!(LUA, "root", { + f.render_widget(crate::tasks::Progress::new(&self.core), f.area()); + f.render_widget(crate::notify::Notify::new(&self.core), f.area()); + Ok(()) + }) + }); + })?; if COLLISION.load(Ordering::Relaxed) { Self::patch(frame);