diff --git a/yazi-core/src/tab/commands/preview.rs b/yazi-core/src/tab/commands/preview.rs index 6c35dabc..9951eab0 100644 --- a/yazi-core/src/tab/commands/preview.rs +++ b/yazi-core/src/tab/commands/preview.rs @@ -23,7 +23,7 @@ impl Tab { return; }; - if hovered != &opt.lock.url { + if opt.lock.url != *hovered { return; } diff --git a/yazi-fm/src/app/app.rs b/yazi-fm/src/app/app.rs index 2288f3be..c4356934 100644 --- a/yazi-fm/src/app/app.rs +++ b/yazi-fm/src/app/app.rs @@ -33,7 +33,7 @@ impl App { Event::Call(exec, layer) => app.dispatch_call(exec, layer), Event::Render => render_in_place = true, Event::Key(key) => app.dispatch_key(key), - Event::Resize(cols, rows) => app.dispatch_resize(cols, rows)?, + Event::Resize => app.resize()?, Event::Paste(str) => app.dispatch_paste(str), Event::Quit(no_cwd_file) => { app.quit(no_cwd_file)?; @@ -65,15 +65,6 @@ impl App { } } - fn dispatch_resize(&mut self, _: u16, _: u16) -> Result<()> { - self.cx.manager.active_mut().preview.reset(); - self.render()?; - - self.cx.manager.current_mut().sync_page(true); - self.cx.manager.peek(false); - Ok(()) - } - #[inline] fn dispatch_call(&mut self, exec: Vec, layer: Layer) { Executor::new(self).dispatch(&exec, layer); diff --git a/yazi-fm/src/app/commands/mod.rs b/yazi-fm/src/app/commands/mod.rs index f5d96232..504f5186 100644 --- a/yazi-fm/src/app/commands/mod.rs +++ b/yazi-fm/src/app/commands/mod.rs @@ -1,4 +1,5 @@ mod plugin; mod quit; mod render; +mod resize; mod stop; diff --git a/yazi-fm/src/app/commands/resize.rs b/yazi-fm/src/app/commands/resize.rs new file mode 100644 index 00000000..b1c2d15c --- /dev/null +++ b/yazi-fm/src/app/commands/resize.rs @@ -0,0 +1,14 @@ +use anyhow::Result; + +use crate::app::App; + +impl App { + pub(crate) fn resize(&mut self) -> Result<()> { + self.cx.manager.active_mut().preview.reset(); + self.render()?; + + self.cx.manager.current_mut().sync_page(true); + self.cx.manager.hover(None); + Ok(()) + } +} diff --git a/yazi-fm/src/app/commands/stop.rs b/yazi-fm/src/app/commands/stop.rs index 53ce49bc..4bb93d8d 100644 --- a/yazi-fm/src/app/commands/stop.rs +++ b/yazi-fm/src/app/commands/stop.rs @@ -27,10 +27,10 @@ impl App { } else { self.term = Some(Term::start().unwrap()); self.signals.stop_term(false); - // FIXME: find a better way to handle this - self.render().unwrap(); - self.cx.manager.hover(None); - self.cx.manager.peek(true); + + // While the app resumes, it's possible that the terminal size has changed. + // We need to trigger a resize, and render the UI based on the resized area. + self.resize().unwrap(); } if let Some(tx) = opt.tx { tx.send(()).ok(); diff --git a/yazi-fm/src/signals.rs b/yazi-fm/src/signals.rs index 17fdfda1..db3f4f0f 100644 --- a/yazi-fm/src/signals.rs +++ b/yazi-fm/src/signals.rs @@ -88,7 +88,7 @@ impl Signals { // otherwise event will be dispatched twice. CrosstermEvent::Key(key @ KeyEvent { kind: KeyEventKind::Press, .. }) => Event::Key(key), CrosstermEvent::Paste(str) => Event::Paste(str), - CrosstermEvent::Resize(cols, rows) => Event::Resize(cols, rows), + CrosstermEvent::Resize(..) => Event::Resize, _ => continue, }; if tx.send(event).is_err() { diff --git a/yazi-plugin/src/loader.rs b/yazi-plugin/src/loader.rs index acb7f927..f2574bbb 100644 --- a/yazi-plugin/src/loader.rs +++ b/yazi-plugin/src/loader.rs @@ -22,7 +22,8 @@ impl Loader { return Ok(()); } - let b = fs::read(BOOT.plugin_dir.join(name)).await.map(|v| v.into()).or_else(|_| { + let path = BOOT.plugin_dir.join(format!("{name}.yazi/init.lua")); + let b = fs::read(path).await.map(|v| v.into()).or_else(|_| { Ok(Cow::from(match name { "noop.lua" => include_bytes!("../preset/plugins/noop.lua") as &[u8], "archive.lua" => include_bytes!("../preset/plugins/archive.lua"), diff --git a/yazi-plugin/src/plugin.rs b/yazi-plugin/src/plugin.rs index f32799ff..e463cb28 100644 --- a/yazi-plugin/src/plugin.rs +++ b/yazi-plugin/src/plugin.rs @@ -33,7 +33,7 @@ pub fn init() { fn stage_2(lua: &Lua) { let setup = br#" ya.SYNC_ON = true -package.path = BOOT.plugin_dir .. "/?.yazi/init.lua;" .. BOOT.plugin_dir .. "/?.lua;" .. package.path +package.path = BOOT.plugin_dir .. "/?.yazi/init.lua;" .. package.path "#; lua.load(setup as &[u8]).exec().unwrap(); diff --git a/yazi-shared/src/event/event.rs b/yazi-shared/src/event/event.rs index a71d2a55..c6e2d49c 100644 --- a/yazi-shared/src/event/event.rs +++ b/yazi-shared/src/event/event.rs @@ -11,7 +11,7 @@ pub enum Event { Call(Vec, Layer), Render, Key(KeyEvent), - Resize(u16, u16), + Resize, Paste(String), Quit(bool), // no-cwd-file }