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
Middle-clicked folders in the sidebar, tree, address bar and bookmarks follow the new-tab setting
gelenmedya1be9a39bad22
diff --git a/crates/rf-app/src/bookmarks_bar.rs b/crates/rf-app/src/bookmarks_bar.rsindex c1707ea0..f5db5d8d 100644--- a/crates/rf-app/src/bookmarks_bar.rs+++ b/crates/rf-app/src/bookmarks_bar.rs@@ -382,7 +382,7 @@ impl Workspace {if this.bookmark_rename.as_ref().is_some_and(|(at, _, _)| *at == i) {return;}- let new_tab = ev.modifiers().control;+ let new_tab = ev.modifiers().control.then_some(ev.modifiers().shift);match &clicked {Bookmark::Link { target, .. } => this.open_bookmark(target, new_tab, window, cx),Bookmark::Folder { children, .. } => {@@ -393,9 +393,9 @@ impl Workspace {}}))// the middle button: in a new tab, as in a browser- .on_mouse_down(MouseButton::Middle, cx.listener(move |this, _: &MouseDownEvent, window, cx| {+ .on_mouse_down(MouseButton::Middle, cx.listener(move |this, ev: &MouseDownEvent, window, cx| {if let Bookmark::Link { target, .. } = &middle {- this.open_bookmark(target, true, window, cx);+ this.open_bookmark(target, Some(ev.modifiers.shift), window, cx);}})).on_mouse_down(MouseButton::Right, cx.listener(move |this, ev: &MouseDownEvent, window, cx| {@@ -406,12 +406,13 @@ impl Workspace {}/// Opens a bookmark: a folder in this tab (or a new one), a file with its program, a web address in the browser.- pub(super) fn open_bookmark(&mut self, target: &str, new_tab: bool, window: &mut Window, cx: &mut Context<Self>) {+ /// `new_tab`: `None` opens it in the active tab, `Some(shift)` in a new tab placed as the setting says (see `open_tab_as_set`).+ pub(super) fn open_bookmark(&mut self, target: &str, new_tab: Option<bool>, window: &mut Window, cx: &mut Context<Self>) {match bookmarks::local_path(target) {Some(path) if !path.is_file() => {let loc = Location::Path(path);- if new_tab {- self.open_tab(loc, window, cx);+ if let Some(shift) = new_tab {+ self.open_tab_as_set(loc, shift, window, cx);} else {self.active_tab().clone().update(cx, |v, cx| v.navigate(loc, cx));}@@ -441,12 +442,12 @@ impl Workspace {if let Bookmark::Link { target, .. } = b {let (m, t) = (me.clone(), target.clone());v.push(Item::action(t!("Aç"), icon(L::SquareArrowOutUpRight), move |w, cx| {- let _ = m.update(cx, |ws, cx| ws.open_bookmark(&t, false, w, cx));+ let _ = m.update(cx, |ws, cx| ws.open_bookmark(&t, None, w, cx));}));if bookmarks::local_path(target).is_some() {let (m, t) = (me.clone(), target.clone());v.push(Item::action(t!("Yeni sekmede aç"), icon(L::Plus), move |w, cx| {- let _ = m.update(cx, |ws, cx| ws.open_bookmark(&t, true, w, cx));+ let _ = m.update(cx, |ws, cx| ws.open_bookmark(&t, Some(false), w, cx));}));}}@@ -609,7 +610,7 @@ fn bookmark_items(me: WeakEntity<Workspace>, list: &[Bookmark]) -> Vec<Item> {let (m, t) = (me.clone(), target.clone());let icon = if bookmarks::local_path(target).is_some() { MenuIcon::Lucide(L::Folder) } else { MenuIcon::Lucide(L::Globe) };Item::action(name.clone(), icon, move |w, cx| {- let _ = m.update(cx, |ws, cx| ws.open_bookmark(&t, false, w, cx));+ let _ = m.update(cx, |ws, cx| ws.open_bookmark(&t, None, w, cx));})}Bookmark::Folder { name, children } => Item::sub(name.clone(), MenuIcon::Lucide(L::Folder), bookmark_items(me.clone(), children)),diff --git a/crates/rf-app/src/sidebar_tree.rs b/crates/rf-app/src/sidebar_tree.rsindex 165eb308..b6574784 100644--- a/crates/rf-app/src/sidebar_tree.rs+++ b/crates/rf-app/src/sidebar_tree.rs@@ -123,8 +123,8 @@ const FIRST_FRAME_ROWS: usize = 40;pub enum TreeEvent {/// A click, Enter: show this folder in the active pane. The focus stays in the tree.Navigate(PathBuf),- /// Ctrl+click, middle click: open it in a new tab.- OpenTab(PathBuf),+ /// Ctrl+click, middle click: open it in a new tab (Shift held: the other way round from the setting, this once).+ OpenTab(PathBuf, bool),/// Right click: the same menu a sidebar folder gets (Shift held: Windows' own menu, as on the sidebar's rows).Menu(PathBuf),/// The menu key, Shift+F10: the sidebar's folder menu next to the row (the point), never Windows' classic menu.@@ -506,7 +506,7 @@ impl SidebarTree {let Some(path) = self.model.path_of(id).map(Path::to_path_buf) else { return };if ctrl {self.model.set_cursor(id);- cx.emit(TreeEvent::OpenTab(path));+ cx.emit(TreeEvent::OpenTab(path, false));} else {self.select(id, path, cx);}@@ -953,9 +953,9 @@ impl SidebarTree {).on_mouse_down(MouseButton::Middle,- cx.listener(move |this, _: &MouseDownEvent, _, cx| {+ cx.listener(move |this, ev: &MouseDownEvent, _, cx| {if let Some(path) = this.model.path_of(id).map(Path::to_path_buf) {- cx.emit(TreeEvent::OpenTab(path));+ cx.emit(TreeEvent::OpenTab(path, ev.modifiers.shift));}}),)@@ -1108,11 +1108,7 @@ impl Workspace {self.active_tab().clone().update(cx, |v, cx| v.navigate(Location::Path(path.clone()), cx));self.search.update(cx, |s, cx| s.set_value("", window, cx));}- TreeEvent::OpenTab(path) => {- let keep = self.active;- self.open_tab(Location::Path(path.clone()), window, cx);- self.activate(keep, window, cx);- }+ TreeEvent::OpenTab(path, shift) => self.open_tab_as_set(Location::Path(path.clone()), *shift, window, cx),TreeEvent::Menu(path) => self.sidebar_menu(path.clone(), window, cx),// from the keyboard: not the physical Shift key's classic menu, and next to the row, not at the mouseTreeEvent::KeyMenu(path, at) => self.sidebar_menu_at(path.clone(), false, *at, window, cx),diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 94f9e8e8..0bc8b53d 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -1564,6 +1564,17 @@ impl Workspace {if self.tabs.get(self.active).is_some_and(shows) { Some(self.active) } else { self.tabs.iter().position(shows) }}+ /// A folder opened in a new tab from outside the file list (the sidebar, the folder tree, the address bar, a bookmark), by a+ /// middle click or Ctrl+click: in front or behind as Settings › General › "Always switch to a newly opened tab" says, the+ /// same as from the list; `shift` turns it round for this one click, as in browsers.+ pub(crate) fn open_tab_as_set(&mut self, loc: Location, shift: bool, window: &mut Window, cx: &mut Context<Self>) {+ let keep = self.active;+ self.open_tab(loc, window, cx);+ if cx.global::<crate::settings::Settings>().focus_new_tab == shift {+ self.activate(keep, window, cx);+ }+ }+pub fn open_tab(&mut self, loc: Location, window: &mut Window, cx: &mut Context<Self>) {// Settings and the Recycle Bin are one tab per window: a second request goes to the tab that is there (issues 281, 300).// Home is not in this rule: a new tab IS a Home tab.@@ -4523,11 +4534,9 @@ impl Workspace {}).on_mouse_down(MouseButton::Middle, {let target = target.clone();- cx.listener(move |this, _: &MouseDownEvent, window, cx| {+ cx.listener(move |this, ev: &MouseDownEvent, window, cx| {cx.stop_propagation();- let keep = this.active;- this.open_tab(target.clone(), window, cx);- this.activate(keep, window, cx);+ this.open_tab_as_set(target.clone(), ev.modifiers.shift, window, cx);})}).on_click(cx.listener(move |this, _, window, cx| {@@ -4859,7 +4868,7 @@ impl Workspace {}).on_mouse_down(MouseButton::Middle,- cx.listener(move |this, _: &MouseDownEvent, window, cx| {+ cx.listener(move |this, ev: &MouseDownEvent, window, cx| {// Home and the Recycle Bin that are open already: their tab comes forward, no second one (issue 300)if matches!(target2, Location::Home | Location::RecycleBin)&& let Some(ix) = this.tab_showing(&target2, cx)@@ -4867,9 +4876,7 @@ impl Workspace {this.activate(ix, window, cx);return;}- let keep = this.active;- this.open_tab(target2.clone(), window, cx);- this.activate(keep, window, cx);+ this.open_tab_as_set(target2.clone(), ev.modifiers.shift, window, cx);}),).when_some(drop_dir, |d, dir| {