Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Improve recent projects search result ordering (#38795)

tsjason1e70a1a4ce52
diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs
index 2b3292288ae..a0753d9549a 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