A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
A click on a folder of the address bar keeps one's place in it, as Up does (1003)
denfryd262eac82c0d
diff --git a/crates/rf-app/src/folder_view.rs b/crates/rf-app/src/folder_view.rsindex 8cee6891..ae7d1cc5 100644--- a/crates/rf-app/src/folder_view.rs+++ b/crates/rf-app/src/folder_view.rs@@ -1394,6 +1394,21 @@ impl FolderView {}}+ /// Goes to `to`; when it is a folder above the one shown (a click on a folder of the address bar), as Up does it, any number of+ /// levels at once: the list comes back where it stood in that folder and the folder one came down through is selected, under the+ /// same setting (issue 1003: back to the top of the list instead). Anything else is an ordinary visit.+ pub fn go_up_to(&mut self, to: Location, cx: &mut Context<Self>) {+ let Some(name) = rf_core::history::child_toward(self.location(), &to) else {+ self.navigate(to, cx);+ return;+ };+ if self.view_mode == ViewMode::Columns || cx.global::<crate::settings::Settings>().select_previous_on_up {+ self.reselect = Some(name);+ }+ self.return_to_place(&to);+ self.navigate(to, cx);+ }+fn ensure_column(&mut self, dir: PathBuf, cx: &mut Context<Self>) {if self.column_cache.contains_key(&dir) || !self.column_pending.insert(dir.clone()) {return;diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 42d7c2f5..017c8092 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -2256,6 +2256,18 @@ impl Workspace {self.focus_active(window, cx);}+ /// A click on a folder of the address bar: a folder above the one shown is gone up to as Up goes, keeping one's place in it+ /// (`FolderView::go_up_to`, issue 1003); any other is an ordinary visit.+ fn go_by_crumb(&mut self, loc: Location, window: &mut Window, cx: &mut Context<Self>) {+ if rf_core::history::child_toward(self.active_tab().read(cx).location(), &loc).is_none() {+ self.navigate(loc, window, cx);+ return;+ }+ self.active_tab().clone().update(cx, |v, cx| v.go_up_to(loc, cx));+ self.search.update(cx, |s, cx| s.set_value("", window, cx));+ self.focus_active(window, cx);+ }+fn toggle_shelf(&mut self, cx: &mut Context<Self>) {self.shelf_open = !self.shelf_open;if self.shelf_open {@@ -4578,7 +4590,7 @@ impl Workspace {}).on_click(cx.listener(move |this, _, window, cx| {cx.stop_propagation();- this.navigate(target.clone(), window, cx);+ this.go_by_crumb(target.clone(), window, cx);})),);}diff --git a/crates/rf-core/src/history.rs b/crates/rf-core/src/history.rsindex 63bf8441..3f3fafb7 100644--- a/crates/rf-core/src/history.rs+++ b/crates/rf-core/src/history.rs@@ -231,6 +231,16 @@ pub fn came_from(from: &Location, to: &Location) -> Option<String> {Some(child.file_name()?.to_string_lossy().into_owned())}+/// The name of the folder of `from`'s path that is right inside `to`, when `to` is a folder above `from` (any number of levels): the+/// one to select after going up to `to` in one step, as a click on a folder of the address bar does (issue 1003). `None` when `to`+/// is not above `from`.+pub fn child_toward(from: &Location, to: &Location) -> Option<String> {+ let (from, to) = (from.path()?, to.path()?);+ let spelled = |p: &std::path::Path| p.to_string_lossy().trim_end_matches(['\\', '/']).to_ascii_lowercase();+ let target = spelled(to);+ from.ancestors().find(|a| a.parent().is_some_and(|p| spelled(p) == target)).and_then(|a| Some(a.file_name()?.to_string_lossy().into_owned()))+}+/// Browser-style back/forward history.#[derive(Debug, Clone)]pub struct History {@@ -541,7 +551,7 @@ mod search_ms_tests {#[cfg(test)]mod came_from_tests {- use super::came_from;+ use super::{came_from, child_toward};use crate::Location;use std::path::PathBuf;@@ -564,6 +574,21 @@ mod came_from_tests {assert_eq!(came_from(&Location::Home, &at(r"C:\A")), None);assert_eq!(came_from(&at(r"C:\"), &at(r"C:\")), None, "a drive's root has no name");}++ #[test]+ #[cfg_attr(not(windows), ignore = "Windows paths and APIs; a Unix test comes when the Mac port uses this")]+ fn a_folder_above_names_the_one_inside_it_on_the_way() {+ assert_eq!(child_toward(&at(r"C:\A\B"), &at(r"C:\A")), Some("B".to_string()), "one level up");+ assert_eq!(child_toward(&at(r"C:\A\B\C\D"), &at(r"C:\A")), Some("B".to_string()), "several levels up");+ assert_eq!(child_toward(&at(r"C:\A\B\C"), &at(r"C:\")), Some("A".to_string()), "up to the drive's root");+ assert_eq!(child_toward(&at(r"C:\A\B\"), &at(r"c:\a")), Some("B".to_string()), "however the two are spelled");+ // not above: an ordinary visit+ assert_eq!(child_toward(&at(r"C:\A\B"), &at(r"C:\A\B")), None, "the folder itself");+ assert_eq!(child_toward(&at(r"C:\A"), &at(r"C:\A\B")), None, "down");+ assert_eq!(child_toward(&at(r"C:\AB\C"), &at(r"C:\A")), None, "a name that only starts the same");+ assert_eq!(child_toward(&at(r"D:\A\B"), &at(r"C:\A")), None, "another drive");+ assert_eq!(child_toward(&at(r"C:\A\B"), &Location::Home), None);+ }}#[cfg(all(test, unix))]