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
Keep the unselected focus only for a Ctrl+arrow walk
Marcos8ead8c514e68
diff --git a/crates/rf-app/src/folder_view.rs b/crates/rf-app/src/folder_view.rsindex f4c52cd6..7ebd8925 100644--- a/crates/rf-app/src/folder_view.rs+++ b/crates/rf-app/src/folder_view.rs@@ -826,6 +826,9 @@ pub struct FolderView {sortx: sort_ext::SortxState,cursor: Option<usize>,anchor: Option<usize>,+ /// The cursor was moved with Ctrl+arrows and no selection change has happened since: the focus outline may rest on an+ /// unselected item and `cursor_entry()` follows it (see `move_focus`). Cleared by every other selection change.+ focus_walk: bool,pub loading: bool,pub error: Option<String>,pub load_ms: Option<u128>,@@ -1123,6 +1126,7 @@ impl FolderView {sortx: Default::default(),cursor: None,anchor: None,+ focus_walk: false,loading: false,error: None,load_ms: None,@@ -2093,6 +2097,7 @@ impl FolderView {self.selected.clear();self.cursor = None;self.anchor = None;+ self.focus_walk = false;self.error = None;self.load_ms = None;self.scroll.scroll_to_item(0, ScrollStrategy::Top);@@ -2646,6 +2651,7 @@ impl FolderView {}self.cursor = found.first().copied();self.anchor = found.first().copied();+ self.focus_walk = false;let line = self.scroll_line(found[0]);self.scroll.scroll_to_item(line, ScrollStrategy::Center);cx.notify();@@ -2831,6 +2837,7 @@ impl FolderView {.filter(|(_, e)| selected_names.contains(&e.name)).map(|(i, _)| i as u32).collect();+ self.focus_walk = false;if trace_live() {log::info!("live: update of {} entries, relisted in {} ms, applied in {} ms; selected {} of {}, cursor {:?}",@@ -3045,6 +3052,7 @@ impl FolderView {if let Some(c) = self.cursor {if c >= self.visible.len() {self.cursor = None;+ self.focus_walk = false;}}}@@ -3464,6 +3472,7 @@ impl FolderView {fn select_only(&mut self, vi: usize) {self.selected.clear();+ self.focus_walk = false;if let Some(&ei) = self.visible.get(vi) {self.selected.insert(ei);self.cursor = Some(vi);@@ -3472,6 +3481,7 @@ impl FolderView {}fn select_range(&mut self, from: usize, to: usize) {+ self.focus_walk = false;self.cursor = Some(select_between(&mut self.selected, &self.visible, from, to));}@@ -3490,6 +3500,7 @@ impl FolderView {}};self.cursor = Some(vi);+ self.focus_walk = false;self.reveal_item(vi);cx.notify();}@@ -3553,6 +3564,7 @@ impl FolderView {}let Some(next) = self.next_index(delta) else { return };self.cursor = Some(next);+ self.focus_walk = true;self.reveal_item(next);cx.notify();}@@ -4235,8 +4247,8 @@ impl FolderView {.when(selected && !renaming_here, |d| d.bg(p.selection).border_1().border_color(p.selection_border)).when(selected && renaming_here, |d| d.bg(p.selection).border_1().border_color(transparent_black())).when(!selected, |d| d.border_1().border_color(transparent_black()))- // the keyboard focus on an item that is not selected (Ctrl+arrows): the outline alone- .when(is_cursor && !selected, |d| d.border_1().border_color(p.selection_border))+ // the keyboard focus walked off the selection (Ctrl+arrows): the outline alone+ .when(is_cursor && !selected && self.focus_walk, |d| d.border_1().border_color(p.selection_border)).when(!selected && part.is_none(), |d| d.hover(|s| s.bg(hover))).when(!selected && part.is_some() && self.grid_hover.is_some_and(|(h, _)| h == vi), |d| d.bg(hover)).on_mouse_down(@@ -4368,6 +4380,7 @@ impl FolderView {}self.cursor = Some(vi);self.anchor = Some(vi);+ self.focus_walk = false;self.reveal_item(vi);} else if !self.selected.contains(&ei) {self.select_only(vi);@@ -4375,6 +4388,7 @@ impl FolderView {} else {// Clicking inside an existing multi-selection keeps it (so it can be dragged).self.cursor = Some(vi);+ self.focus_walk = false;self.reveal_item(vi);if self.selected.len() > 1 {on_release = Release::SelectOnly;@@ -4878,6 +4892,7 @@ impl FolderView {}}self.selected = sel;+ self.focus_walk = false;cx.notify();}@@ -5332,10 +5347,11 @@ impl FolderView {/// Entry under the keyboard cursor, else the single selected entry.pub(crate) fn cursor_entry(&self) -> Option<u32> {- // the cursor can rest on an item that is not selected (Ctrl+arrows move the focus alone): keyboard commands- // (Quick Look on Space, for one) still act on it+ // the cursor rests on an unselected item only after a Ctrl+arrow walk (`focus_walk`): keyboard commands (Quick Look+ // on Space, for one) then act on it; after any other change the cursor only answers when that item is selectedself.cursor.and_then(|c| self.visible.get(c).copied())+ .filter(|ei| self.focus_walk || self.selected.contains(ei)).or_else(|| (self.selected.len() == 1).then(|| *self.selected.iter().next().unwrap()))}@@ -6508,7 +6524,7 @@ impl FolderView {.when(!selected, |d| d.hover(|s| s.bg(if alternating { p.stripe_hover() } else { p.hover })))// the focused one of several: an outline laid over the row, not a border of it, which moved the row's content and its// pill a pixel (issue 276)- .when(is_cursor && (!selected || self.selected.len() > 1), |d| {+ .when(is_cursor && ((selected && self.selected.len() > 1) || (self.focus_walk && !selected)), |d| {d.child(div().absolute().inset_0().rounded(theme::RADIUS_SM).border_1().border_color(p.selection_border))}).on_mouse_down(@@ -6761,6 +6777,7 @@ impl FolderView {}if !(ev.modifiers.control || ev.modifiers.shift) && !this.selected.is_empty() {this.selected.clear();+ this.focus_walk = false;cx.notify();}this.begin_marquee(ev);@@ -6772,6 +6789,7 @@ impl FolderView {this.hover_pick = None;window.focus(&this.focus, cx);this.selected.clear();+ this.focus_walk = false;cx.notify();this.show_context_menu(true, window, cx);}),@@ -8214,12 +8232,14 @@ impl Render for FolderView {.on_action(cx.listener(|this, _: &ExtendLast, _, cx| this.move_cursor(isize::MAX / 2, true, cx))).on_action(cx.listener(|this, _: &SelectAll, _, cx| {this.selected = this.visible.iter().copied().collect();+ this.focus_walk = false;cx.notify();})).on_action(cx.listener(|this, _: &ToggleAllGroups, _, cx| this.toggle_all_groups(cx))).on_action(cx.listener(|this, _: &InvertSelection, _, cx| {let next: HashSet<u32> = this.visible.iter().copied().filter(|i| !this.selected.contains(i)).collect();this.selected = next;+ this.focus_walk = false;cx.notify();})).on_action(cx.listener(|this, _: &ToggleSelection, _, cx| {@@ -8240,6 +8260,7 @@ impl Render for FolderView {return;}this.selected.clear();+ this.focus_walk = false;cx.emit(FolderEvent::Escape);cx.notify();}))@@ -8944,12 +8965,14 @@ impl FolderView {/// Every shown item selected (the toolbar's "…" menu; Ctrl+A does the same through its action).pub(crate) fn select_all_items(&mut self, cx: &mut Context<Self>) {self.selected = self.visible.iter().copied().collect();+ self.focus_walk = false;cx.notify();}/// Nothing selected; the cursor stays where it is.pub(crate) fn select_no_items(&mut self, cx: &mut Context<Self>) {self.selected.clear();+ self.focus_walk = false;cx.notify();}@@ -8957,6 +8980,7 @@ impl FolderView {pub(crate) fn invert_selected_items(&mut self, cx: &mut Context<Self>) {let next: HashSet<u32> = self.visible.iter().copied().filter(|i| !self.selected.contains(i)).collect();self.selected = next;+ self.focus_walk = false;cx.notify();}}