From 8b773a62a546411b7c75cd5af60663ab09fbd278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Mon, 23 Feb 2026 19:01:04 +0800 Subject: [PATCH] fix: make group order of files from flat view stable on select (#3712) --- yazi-core/src/tab/selected.rs | 3 +-- yazi-fs/src/sorter.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/yazi-core/src/tab/selected.rs b/yazi-core/src/tab/selected.rs index f5272908..2676e0ac 100644 --- a/yazi-core/src/tab/selected.rs +++ b/yazi-core/src/tab/selected.rs @@ -29,7 +29,7 @@ impl Selected { I: IntoIterator, T: Into>, { - let mut grouped: HashMap<_, Vec<_>> = Default::default(); + let mut grouped: IndexMap<_, Vec<_>> = Default::default(); for url in urls.into_iter().map(Into::into) { if let Some(p) = url.parent() { grouped.entry(p).or_default().push(url); @@ -71,7 +71,6 @@ impl Selected { urls.len() } - #[inline] pub fn remove<'a>(&mut self, url: impl Into> + Clone) -> bool { self.remove_same([url]) == 1 } diff --git a/yazi-fs/src/sorter.rs b/yazi-fs/src/sorter.rs index cadeea30..af21f4d3 100644 --- a/yazi-fs/src/sorter.rs +++ b/yazi-fs/src/sorter.rs @@ -59,11 +59,11 @@ impl FilesSorter { }), SortBy::Alphabetical => items.sort_unstable_by(|a, b| { promote!(a, b); - self.sort_alphabetically(a, b) + self.fallback(a, b, self.sort_alphabetically(a, b)) }), SortBy::Natural => items.sort_unstable_by(|a, b| { promote!(a, b); - self.sort_naturally(a, b) + self.fallback(a, b, self.sort_naturally(a, b)) }), SortBy::Size => items.sort_unstable_by(|a, b| { promote!(a, b);