diff --git a/yazi-core/src/manager/manager.rs b/yazi-core/src/manager/manager.rs index 4efd9b27..34f01fa4 100644 --- a/yazi-core/src/manager/manager.rs +++ b/yazi-core/src/manager/manager.rs @@ -60,11 +60,11 @@ impl Manager { pub fn current_mut(&mut self) -> &mut Folder { &mut self.active_mut().current } #[inline] - pub fn current_or(&self, idx: Option) -> &Folder { &self.active_or(idx).current } + pub fn current_or(&self, id: Option) -> &Folder { &self.active_or(id).current } #[inline] - pub fn current_or_mut(&mut self, idx: Option) -> &mut Folder { - &mut self.active_or_mut(idx).current + pub fn current_or_mut(&mut self, id: Option) -> &mut Folder { + &mut self.active_or_mut(id).current } #[inline] diff --git a/yazi-core/src/manager/tabs.rs b/yazi-core/src/manager/tabs.rs index 1dfce8f1..4ddcf99e 100644 --- a/yazi-core/src/manager/tabs.rs +++ b/yazi-core/src/manager/tabs.rs @@ -69,6 +69,9 @@ impl Tabs { self.active_mut() } } + + #[inline] + pub fn find_mut(&mut self, id: Id) -> Option<&mut Tab> { self.iter_mut().find(|t| t.id == id) } } impl Deref for Tabs { diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index c75069fd..27c27d87 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -55,7 +55,13 @@ impl<'a> Executor<'a> { }; (ACTIVE, $name:ident $(,$args:expr)*) => { if cmd.name == stringify!($name) { - return self.app.cx.manager.active_mut().$name(cmd, $($args),*); + return if let Some(tab) = cmd.get("tab") { + let Some(id) = tab.as_id() else { return }; + let Some(tab) = self.app.cx.manager.tabs.find_mut(id) else { return }; + tab.$name(cmd, $($args),*) + } else { + self.app.cx.manager.active_mut().$name(cmd, $($args),*) + }; } }; (TABS, $name:ident) => {