From 1e70a1a4ce52ce0a32ee6b328b112579b05296c2 Mon Sep 17 00:00:00 2001 From: tsjason Date: Mon, 29 Sep 2025 10:15:47 -0500 Subject: [PATCH] Improve recent projects search result ordering (#38795) Previously, search results were sorted solely by candidate_id (preserving original order from the database), which could result in less relevant matches appearing before better ones. This change sorts results primarily by fuzzy match score (descending), with candidate_id as a tiebreaker for equal scores. This ensures that better matches appear first while preserving recency order among items with identical scores. Example improvement: - Searching for 'pica' will now rank 'picabo' higher than scattered matches like 'project-api, project-chat' - Consecutive character matches are prioritized over scattered matches across multiple path segments Release Notes: - Improved project search relevance by ranking results using match score instead of insertion order. --- crates/recent_projects/src/recent_projects.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index 2b3292288ae866036db70e2b832af9fc06d443e0..a0753d9549a292f274a84acb5e08f5ac7ab5c09f 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -328,7 +328,12 @@ impl PickerDelegate for RecentProjectsDelegate { &Default::default(), cx.background_executor().clone(), )); - self.matches.sort_unstable_by_key(|m| m.candidate_id); + self.matches.sort_unstable_by(|a, b| { + b.score + .partial_cmp(&a.score) // Descending score + .unwrap_or(std::cmp::Ordering::Equal) + .then_with(|| a.candidate_id.cmp(&b.candidate_id)) // Ascending candidate_id for ties + }); if self.reset_selected_match_index { self.selected_match_index = self