From c4ffdc08bb4b9599bf4243ed0adb17b593cdd41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Thu, 26 Sep 2024 08:50:07 +0800 Subject: [PATCH] fix: `enter` and `leave` commands should treat the search results as regular entities (#1687) --- yazi-core/src/manager/commands/peek.rs | 2 +- yazi-core/src/manager/commands/seek.rs | 2 +- yazi-core/src/manager/commands/tab_create.rs | 4 ++-- yazi-core/src/tab/commands/enter.rs | 2 +- yazi-core/src/tab/commands/leave.rs | 4 ++-- yazi-shared/src/fs/file.rs | 3 --- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/yazi-core/src/manager/commands/peek.rs b/yazi-core/src/manager/commands/peek.rs index 2c1c1f14..58f50b95 100644 --- a/yazi-core/src/manager/commands/peek.rs +++ b/yazi-core/src/manager/commands/peek.rs @@ -1,4 +1,4 @@ -use yazi_shared::{event::{Cmd, Data}, fs::Url, render}; +use yazi_shared::{event::{Cmd, Data}, fs::Url}; use crate::manager::Manager; diff --git a/yazi-core/src/manager/commands/seek.rs b/yazi-core/src/manager/commands/seek.rs index 8f2de721..13dfe1c8 100644 --- a/yazi-core/src/manager/commands/seek.rs +++ b/yazi-core/src/manager/commands/seek.rs @@ -1,6 +1,6 @@ use yazi_config::PLUGIN; use yazi_plugin::isolate; -use yazi_shared::{MIME_DIR, event::{Cmd, Data}, render}; +use yazi_shared::{MIME_DIR, event::{Cmd, Data}}; use crate::manager::Manager; diff --git a/yazi-core/src/manager/commands/tab_create.rs b/yazi-core/src/manager/commands/tab_create.rs index acf7be81..56efc499 100644 --- a/yazi-core/src/manager/commands/tab_create.rs +++ b/yazi-core/src/manager/commands/tab_create.rs @@ -42,11 +42,11 @@ impl Tabs { } else if let Some(h) = self.active().current.hovered() { tab.conf = self.active().conf.clone(); tab.apply_files_attrs(); - tab.reveal(h.url_owned()); + tab.reveal(h.url.to_regular()); } else { tab.conf = self.active().conf.clone(); tab.apply_files_attrs(); - tab.cd(self.active().cwd().to_owned()); + tab.cd(self.active().cwd().to_regular()); } self.items.insert(self.cursor + 1, tab); diff --git a/yazi-core/src/tab/commands/enter.rs b/yazi-core/src/tab/commands/enter.rs index 720ca3b7..87e44cab 100644 --- a/yazi-core/src/tab/commands/enter.rs +++ b/yazi-core/src/tab/commands/enter.rs @@ -4,6 +4,6 @@ use crate::tab::Tab; impl Tab { pub fn enter(&mut self, _: Cmd) { - self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url_owned()).map(|u| self.cd(u)); + self.current.hovered().filter(|h| h.is_dir()).map(|h| h.url.to_regular()).map(|u| self.cd(u)); } } diff --git a/yazi-core/src/tab/commands/leave.rs b/yazi-core/src/tab/commands/leave.rs index 661fea99..bc85887c 100644 --- a/yazi-core/src/tab/commands/leave.rs +++ b/yazi-core/src/tab/commands/leave.rs @@ -15,9 +15,9 @@ impl Tab { self .current .hovered() - .and_then(|h| h.parent()) + .and_then(|h| h.url.parent_url()) .filter(|u| u != self.cwd()) .or_else(|| self.cwd().parent_url()) - .map(|u| self.cd(u)); + .map(|u| self.cd(u.into_regular())); } } diff --git a/yazi-shared/src/fs/file.rs b/yazi-shared/src/fs/file.rs index b1dc8ff5..4726b856 100644 --- a/yazi-shared/src/fs/file.rs +++ b/yazi-shared/src/fs/file.rs @@ -101,7 +101,4 @@ impl File { #[inline] pub fn stem(&self) -> Option<&OsStr> { self.url.file_stem() } - - #[inline] - pub fn parent(&self) -> Option { self.url.parent_url() } }