mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
24 lines
484 B
Rust
24 lines
484 B
Rust
use yazi_shared::event::CmdCow;
|
|
|
|
use crate::tab::Tab;
|
|
|
|
struct Opt;
|
|
impl From<()> for Opt {
|
|
fn from(_: ()) -> Self { Self }
|
|
}
|
|
impl From<CmdCow> for Opt {
|
|
fn from(_: CmdCow) -> Self { Self }
|
|
}
|
|
|
|
impl Tab {
|
|
#[yazi_codegen::command]
|
|
pub fn leave(&mut self, _: Opt) {
|
|
self
|
|
.current
|
|
.hovered()
|
|
.and_then(|h| h.url.parent_url())
|
|
.filter(|u| u != self.cwd())
|
|
.or_else(|| self.cwd().parent_url())
|
|
.map(|u| self.cd((u.into_regular(), super::cd::OptSource::Leave)));
|
|
}
|
|
}
|