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
Folder tree: double click opens or closes, Collapse all folders (788, 790)
gelenmedya5aaab63a1dc4
diff --git a/crates/rf-app/src/i18n_en.rs b/crates/rf-app/src/i18n_en.rsindex 13b319be..5b33cb3b 100644--- a/crates/rf-app/src/i18n_en.rs+++ b/crates/rf-app/src/i18n_en.rs@@ -1176,6 +1176,7 @@ pub const EN: &[(&str, &str)] = &[("Tüm grupları daralt / genişlet", "Collapse / expand all groups"),("Listeyi sütun sütun doldur", "Fill the List column by column"),("Filtrele", "Filter"),+ ("Tüm klasörleri daralt", "Collapse all folders"),("Bu klasörü filtrele", "Filter this folder"),("Şunlara göre filtrele", "Filter by"),("Dosya adı", "File name"),diff --git a/crates/rf-app/src/sidebar_tree.rs b/crates/rf-app/src/sidebar_tree.rsindex d4791cef..165eb308 100644--- a/crates/rf-app/src/sidebar_tree.rs+++ b/crates/rf-app/src/sidebar_tree.rs@@ -528,6 +528,18 @@ impl SidebarTree {self.after_change(cx);}+ /// Closes every open folder of the tree (issue 790).+ pub fn collapse_all(&mut self, cx: &mut Context<Self>) {+ if self.model.collapse_all(self.now()) {+ self.after_change(cx);+ }+ }++ /// Whether any folder of the tree is open.+ pub fn any_open(&self) -> bool {+ self.model.any_open()+ }+fn retry(&mut self, id: NodeId, cx: &mut Context<Self>) {let reqs = self.model.retry(id, self.now());self.start_loads(reqs, cx);@@ -920,6 +932,11 @@ impl SidebarTree {}).on_click(cx.listener(move |this, ev: &ClickEvent, window, cx| {window.focus(&this.focus, cx);+ // a double click opens or closes the folder, as in File Explorer's tree (issue 788); the first click went there+ if ev.click_count() == 2 && can_expand {+ this.toggle(id, cx);+ return;+ }this.click_row(id, ev.modifiers().control, cx);})).on_mouse_down(diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 53c1b3b1..47e1207d 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -3327,6 +3327,12 @@ impl Workspace {}),));}+ // the folder tree's open folders, all closed at once (issue 790)+ if let Some(tree) = self.side_tree.view().filter(|t| t.read(cx).any_open()) {+ items.push(Item::action(t!("Tüm klasörleri daralt"), MenuIcon::Lucide(L::ChevronsDownUp), move |_, cx| {+ tree.update(cx, |t, cx| t.collapse_all(cx));+ }));+ }items.extend([// our Properties window (a drive gets its own page there)Item::action(t!("Özellikler"), MenuIcon::Lucide(L::Wrench), with(|ws, p, _, cx| {diff --git a/crates/rf-core/src/navtree.rs b/crates/rf-core/src/navtree.rsindex c8975ee5..9afa3f04 100644--- a/crates/rf-core/src/navtree.rs+++ b/crates/rf-core/src/navtree.rs@@ -659,6 +659,28 @@ impl NavTree {reqs}+ /// Closes every open folder (the sidebar's "Collapse all folders", issue 790: a deep walk pushed the drives far down). The roots+ /// close too, so the drives are listed under one another again. Whether anything was open.+ pub fn collapse_all(&mut self, now_ms: u64) -> bool {+ let open: Vec<NodeId> = (0..self.nodes.len() as NodeId)+ .filter(|&id| self.live(id) && self.nodes[id as usize].expanded)+ .collect();+ if open.is_empty() {+ return false;+ }+ for id in open {+ self.collapse_node(id, now_ms, true);+ }+ self.trim();+ self.rebuild();+ true+ }++ /// Whether any folder (a root too) is open (the menu offers "Collapse all folders" then).+ pub fn any_open(&self) -> bool {+ (0..self.nodes.len() as NodeId).any(|id| self.live(id) && self.nodes[id as usize].expanded)+ }+/// List a failed node again (the error row was clicked).pub fn retry(&mut self, id: NodeId, now_ms: u64) -> Vec<LoadRequest> {if !self.live(id) || !matches!(self.nodes[id as usize].load, Load::Failed(_)) {@@ -1352,6 +1374,24 @@ mod tests {assert!(!t.any_loading());}+ #[test]+ fn collapse_all_leaves_only_the_roots() {+ let mut t = tree();+ assert!(!t.any_open());+ let c = id_of(&t, r"C:\");+ let r = t.toggle(c, 0).remove(0);+ t.apply_listing(&r, Ok(items(&["a", "b"])), 0);+ let a = id_of(&t, r"C:\a");+ let r = t.toggle(a, 0).remove(0);+ t.apply_listing(&r, Ok(items(&["deep"])), 0);+ assert!(t.any_open());+ assert!(t.rows().len() > 3);+ assert!(t.collapse_all(5));+ assert_eq!(labels(&t).iter().map(|(d, _)| *d).collect::<Vec<_>>(), [0, 0, 0], "only the three roots");+ assert!(!t.any_open());+ assert!(!t.collapse_all(6), "nothing left to close");+ }+#[test]fn a_localized_name_is_what_is_shown_and_sorted_by() {let mut t = tree();