mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: add a new tab parameter for all tab-specific commands to specify which one (#1885)
This commit is contained in:
parent
6086134d41
commit
362fbebcc5
3 changed files with 13 additions and 4 deletions
|
|
@ -60,11 +60,11 @@ impl Manager {
|
||||||
pub fn current_mut(&mut self) -> &mut Folder { &mut self.active_mut().current }
|
pub fn current_mut(&mut self) -> &mut Folder { &mut self.active_mut().current }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn current_or(&self, idx: Option<Id>) -> &Folder { &self.active_or(idx).current }
|
pub fn current_or(&self, id: Option<Id>) -> &Folder { &self.active_or(id).current }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn current_or_mut(&mut self, idx: Option<Id>) -> &mut Folder {
|
pub fn current_or_mut(&mut self, id: Option<Id>) -> &mut Folder {
|
||||||
&mut self.active_or_mut(idx).current
|
&mut self.active_or_mut(id).current
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@ impl Tabs {
|
||||||
self.active_mut()
|
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 {
|
impl Deref for Tabs {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,13 @@ impl<'a> Executor<'a> {
|
||||||
};
|
};
|
||||||
(ACTIVE, $name:ident $(,$args:expr)*) => {
|
(ACTIVE, $name:ident $(,$args:expr)*) => {
|
||||||
if cmd.name == stringify!($name) {
|
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) => {
|
(TABS, $name:ident) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue