mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
c7cc29e6b0
commit
5d599167a1
2 changed files with 9 additions and 66 deletions
|
|
@ -1,40 +1,9 @@
|
|||
use std::mem;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::{manager::Manager, tab::Tab};
|
||||
|
||||
pub struct Opt;
|
||||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
}
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
}
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn enter(&mut self, _: impl Into<Opt>) {
|
||||
let Some(hovered) = self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url()) else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Current
|
||||
let rep = self.history_new(&hovered);
|
||||
let rep = mem::replace(&mut self.current, rep);
|
||||
if rep.cwd.is_regular() {
|
||||
self.history.insert(rep.cwd.clone(), rep);
|
||||
}
|
||||
|
||||
// Parent
|
||||
if let Some(rep) = self.parent.take() {
|
||||
self.history.insert(rep.cwd.clone(), rep);
|
||||
}
|
||||
self.parent = Some(self.history_new(&hovered.parent_url().unwrap()));
|
||||
|
||||
// Backstack
|
||||
self.backstack.push(hovered);
|
||||
|
||||
Manager::_refresh();
|
||||
render!();
|
||||
pub fn enter(&mut self, _: Cmd) {
|
||||
self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url()).map(|u| self.cd(u));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
use std::mem;
|
||||
use yazi_shared::event::Cmd;
|
||||
|
||||
use yazi_shared::{event::Cmd, render};
|
||||
|
||||
use crate::{manager::Manager, tab::Tab};
|
||||
use crate::tab::Tab;
|
||||
|
||||
pub struct Opt;
|
||||
impl From<()> for Opt {
|
||||
|
|
@ -14,36 +12,12 @@ impl From<Cmd> for Opt {
|
|||
|
||||
impl Tab {
|
||||
pub fn leave(&mut self, _: impl Into<Opt>) {
|
||||
let current = self
|
||||
self
|
||||
.current
|
||||
.hovered()
|
||||
.and_then(|h| h.parent())
|
||||
.filter(|p| *p != self.current.cwd)
|
||||
.or_else(|| self.current.cwd.parent_url());
|
||||
|
||||
let Some(current) = current else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Parent
|
||||
if let Some(rep) = self.parent.take() {
|
||||
self.history.insert(rep.cwd.clone(), rep);
|
||||
}
|
||||
if let Some(parent) = current.parent_url() {
|
||||
self.parent = Some(self.history_new(&parent));
|
||||
}
|
||||
|
||||
// Current
|
||||
let rep = self.history_new(¤t);
|
||||
let rep = mem::replace(&mut self.current, rep);
|
||||
if rep.cwd.is_regular() {
|
||||
self.history.insert(rep.cwd.clone(), rep);
|
||||
}
|
||||
|
||||
// Backstack
|
||||
self.backstack.push(current);
|
||||
|
||||
Manager::_refresh();
|
||||
render!();
|
||||
.or_else(|| self.current.cwd.parent_url())
|
||||
.map(|u| self.cd(u));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue