diff --git a/yazi-core/src/mgr/commands/hover.rs b/yazi-core/src/mgr/commands/hover.rs index 25c418b5..a94dda8c 100644 --- a/yazi-core/src/mgr/commands/hover.rs +++ b/yazi-core/src/mgr/commands/hover.rs @@ -1,5 +1,3 @@ -use std::collections::HashSet; - use yazi_dds::Pubsub; use yazi_macro::render; use yazi_shared::{Id, event::{CmdCow, Data}, url::{Url, Urn}}; @@ -29,21 +27,8 @@ impl Mgr { self.current_or_mut(opt.tab).arrow(0); } - // Repeek - self.peek(false); - // Refresh watcher - let mut to_watch = HashSet::with_capacity(3 * self.tabs.len()); - for tab in self.tabs.iter() { - to_watch.insert(tab.cwd()); - if let Some(ref p) = tab.parent { - to_watch.insert(&p.url); - } - if let Some(h) = tab.hovered().filter(|&h| h.is_dir()) { - to_watch.insert(&h.url); - } - } - self.watcher.watch(to_watch); + self.watch(()); // Publish through DDS Pubsub::pub_from_hover(self.active().id, self.hovered().map(|h| &h.url)); diff --git a/yazi-core/src/mgr/commands/mod.rs b/yazi-core/src/mgr/commands/mod.rs index c184cbe9..6e673412 100644 --- a/yazi-core/src/mgr/commands/mod.rs +++ b/yazi-core/src/mgr/commands/mod.rs @@ -25,5 +25,6 @@ yazi_macro::mod_flat!( update_paged update_tasks update_yanked + watch yank ); diff --git a/yazi-core/src/mgr/commands/refresh.rs b/yazi-core/src/mgr/commands/refresh.rs index 3cc0b95f..cb165df3 100644 --- a/yazi-core/src/mgr/commands/refresh.rs +++ b/yazi-core/src/mgr/commands/refresh.rs @@ -21,7 +21,8 @@ impl Mgr { self.watcher.trigger_dirs(&[self.current()]); } - self.hover(None); + self.watch(()); + self.peek(false); self.update_paged((), tasks); tasks.prework_sorted(&self.current().files); diff --git a/yazi-core/src/mgr/commands/update_files.rs b/yazi-core/src/mgr/commands/update_files.rs index 6220d48f..cfd9dde0 100644 --- a/yazi-core/src/mgr/commands/update_files.rs +++ b/yazi-core/src/mgr/commands/update_files.rs @@ -22,6 +22,7 @@ impl Mgr { return; }; + let revision = self.current().files.revision; let linked: Vec<_> = LINKED.read().from_dir(opt.op.cwd()).map(|u| opt.op.rebase(u)).collect(); for op in [opt.op].into_iter().chain(linked) { self.yanked.apply_op(&op); @@ -29,7 +30,12 @@ impl Mgr { } render!(self.yanked.catchup_revision(false)); - self.active_mut().apply_files_attrs(); + if revision != self.current().files.revision { + self.active_mut().apply_files_attrs(); + self.hover(None); + self.peek(false); + self.update_paged((), tasks); + } } fn update_tab(&mut self, op: FilesOp, tasks: &Tasks) { @@ -71,8 +77,6 @@ impl Mgr { return; } - self.hover(None); // Re-hover - self.update_paged((), tasks); // Update for paged files if calc { tasks.prework_sorted(&self.current().files); } diff --git a/yazi-core/src/mgr/commands/update_paged.rs b/yazi-core/src/mgr/commands/update_paged.rs index 4f0346dc..95dd080f 100644 --- a/yazi-core/src/mgr/commands/update_paged.rs +++ b/yazi-core/src/mgr/commands/update_paged.rs @@ -20,7 +20,7 @@ impl From<()> for Opt { impl Mgr { pub fn update_paged(&mut self, opt: impl TryInto, tasks: &Tasks) { - let Ok(opt) = opt.try_into() else { + let Ok(opt): Result = opt.try_into() else { return; }; @@ -29,7 +29,9 @@ impl Mgr { } let targets = self.current().paginate(opt.page.unwrap_or(self.current().page)); - tasks.fetch_paged(targets, &self.mimetype); - tasks.preload_paged(targets, &self.mimetype); + if !targets.is_empty() { + tasks.fetch_paged(targets, &self.mimetype); + tasks.preload_paged(targets, &self.mimetype); + } } } diff --git a/yazi-core/src/mgr/commands/watch.rs b/yazi-core/src/mgr/commands/watch.rs new file mode 100644 index 00000000..1e493c03 --- /dev/null +++ b/yazi-core/src/mgr/commands/watch.rs @@ -0,0 +1,31 @@ +use std::collections::HashSet; + +use yazi_shared::event::CmdCow; + +use crate::mgr::Mgr; + +struct Opt; + +impl From for Opt { + fn from(_: CmdCow) -> Self { Self } +} +impl From<()> for Opt { + fn from((): ()) -> Self { Self } +} + +impl Mgr { + #[yazi_codegen::command] + pub fn watch(&mut self, _: Opt) { + let mut to_watch = HashSet::with_capacity(3 * self.tabs.len()); + for tab in self.tabs.iter() { + to_watch.insert(tab.cwd()); + if let Some(ref p) = tab.parent { + to_watch.insert(&p.url); + } + if let Some(h) = tab.hovered().filter(|&h| h.is_dir()) { + to_watch.insert(&h.url); + } + } + self.watcher.watch(to_watch); + } +} diff --git a/yazi-core/src/tab/commands/arrow.rs b/yazi-core/src/tab/commands/arrow.rs index 7aaac9a1..b6f2c492 100644 --- a/yazi-core/src/tab/commands/arrow.rs +++ b/yazi-core/src/tab/commands/arrow.rs @@ -37,6 +37,7 @@ impl Tab { } MgrProxy::hover(None, self.id); + MgrProxy::peek(false); render!(); } } diff --git a/yazi-core/src/tab/commands/filter_do.rs b/yazi-core/src/tab/commands/filter_do.rs index ae651002..b28de7a5 100644 --- a/yazi-core/src/tab/commands/filter_do.rs +++ b/yazi-core/src/tab/commands/filter_do.rs @@ -28,6 +28,7 @@ impl Tab { self.current.repos(hovered.as_ref()); if self.hovered().map(|f| f.urn()) != hovered.as_ref().map(|u| u.as_urn()) { MgrProxy::hover(None, self.id); + MgrProxy::peek(false); } render!(); diff --git a/yazi-core/src/tab/commands/hidden.rs b/yazi-core/src/tab/commands/hidden.rs index 2ed6ed13..f199e25d 100644 --- a/yazi-core/src/tab/commands/hidden.rs +++ b/yazi-core/src/tab/commands/hidden.rs @@ -16,6 +16,7 @@ impl Tab { if hovered.as_ref() != self.hovered().map(|f| &f.url) { MgrProxy::hover(hovered, self.id); + MgrProxy::peek(false); } else if self.hovered().is_some_and(|f| f.is_dir()) { MgrProxy::peek(true); } diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index 4c702940..1dcd6890 100644 --- a/yazi-core/src/tab/commands/reveal.rs +++ b/yazi-core/src/tab/commands/reveal.rs @@ -30,7 +30,9 @@ impl Tab { }; self.cd(parent.clone()); + // TODO FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone(), None)]).emit(); MgrProxy::hover(Some(opt.target), self.id); + MgrProxy::peek(false); } } diff --git a/yazi-core/src/tab/commands/sort.rs b/yazi-core/src/tab/commands/sort.rs index 6f5ddce2..d7d7fc17 100644 --- a/yazi-core/src/tab/commands/sort.rs +++ b/yazi-core/src/tab/commands/sort.rs @@ -21,6 +21,7 @@ impl Tab { self.apply_files_attrs(); MgrProxy::hover(None, self.id); + MgrProxy::peek(false); MgrProxy::update_paged(); tasks.prework_sorted(&self.current.files); diff --git a/yazi-fm/src/app/commands/resize.rs b/yazi-fm/src/app/commands/resize.rs index 34ba34f6..e327f11b 100644 --- a/yazi-fm/src/app/commands/resize.rs +++ b/yazi-fm/src/app/commands/resize.rs @@ -20,6 +20,7 @@ impl App { self.cx.current_mut().sync_page(true); self.cx.mgr.hover(None); + self.cx.mgr.peek(false); self.cx.mgr.parent_mut().map(|f| f.arrow(0)); } } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 89b9fce4..1a0af89c 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -78,6 +78,7 @@ impl<'a> Executor<'a> { on!(MGR, update_paged, &self.app.cx.tasks); on!(MGR, update_yanked); on!(MGR, hover); + on!(MGR, watch); on!(MGR, peek); on!(MGR, seek); on!(MGR, spot); diff --git a/yazi-plugin/src/elements/elements.rs b/yazi-plugin/src/elements/elements.rs index b508137e..b9f9a09f 100644 --- a/yazi-plugin/src/elements/elements.rs +++ b/yazi-plugin/src/elements/elements.rs @@ -16,8 +16,6 @@ pub fn compose(lua: &Lua) -> mlua::Result { b"Line" => super::Line::compose(lua)?, b"List" => super::List::compose(lua)?, b"Pad" => super::Pad::compose(lua, true)?, - // TODO: deprecate this - b"Padding" => super::Pad::compose(lua, false)?, b"Pos" => super::Pos::compose(lua)?, b"Rect" => super::Rect::compose(lua)?, b"Row" => super::Row::compose(lua)?, diff --git a/yazi-plugin/src/elements/rect.rs b/yazi-plugin/src/elements/rect.rs index 78b9690d..c678cb3d 100644 --- a/yazi-plugin/src/elements/rect.rs +++ b/yazi-plugin/src/elements/rect.rs @@ -71,11 +71,6 @@ impl UserData for Rect { fn add_methods>(methods: &mut M) { methods.add_method("pad", |_, me, pad: Pad| Ok(me.pad(pad))); - // TODO: deprecate this - methods.add_method("padding", |lua, me, pad: Pad| { - crate::deprecate!(lua, "The `padding()` method of `ui.Rect` has been deprecated, please use `pad()` instead, in your {}"); - Ok(me.pad(pad)) - }); methods.add_method("contains", |_, me, Rect(rect)| Ok(me.contains(rect.into()))); } } diff --git a/yazi-proxy/src/mgr.rs b/yazi-proxy/src/mgr.rs index f8a44c46..793a75dd 100644 --- a/yazi-proxy/src/mgr.rs +++ b/yazi-proxy/src/mgr.rs @@ -21,6 +21,11 @@ impl MgrProxy { emit!(Call(Cmd::args("mgr:hover", &url.map_or_else(Vec::new, |u| vec![u])).with("tab", tab))); } + #[inline] + pub fn watch() { + emit!(Call(Cmd::new("mgr:watch"))); + } + #[inline] pub fn refresh() { emit!(Call(Cmd::new("mgr:refresh")));