Skip to content

Commit 210f21f

Browse files
committed
feat: sort _ items last
1 parent 1d3d54f commit 210f21f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lua/blink/cmp/fuzzy/fuzzy.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,17 @@ pub fn fuzzy(
8585
matches.sort_by_cached_key(|mtch| Reverse(match_scores[mtch.index]));
8686
}
8787
"label" => {
88-
matches.sort_by_key(|mtch| haystack[mtch.index_in_haystack].label.clone());
88+
matches.sort_by(|a, b| {
89+
let label_a = &haystack[a.index_in_haystack].label;
90+
let label_b = &haystack[b.index_in_haystack].label;
91+
92+
// Put anything with an underscore at the end
93+
match (label_a.starts_with('_'), label_b.starts_with('_')) {
94+
(true, false) => std::cmp::Ordering::Greater,
95+
(false, true) => std::cmp::Ordering::Less,
96+
_ => label_a.cmp(label_b),
97+
}
98+
});
8999
}
90100
_ => {}
91101
}

0 commit comments

Comments
 (0)