Skip to content

Commit

Permalink
feat: sort _ items last
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Oct 2, 2024
1 parent 1d3d54f commit 210f21f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lua/blink/cmp/fuzzy/fuzzy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,17 @@ pub fn fuzzy(
matches.sort_by_cached_key(|mtch| Reverse(match_scores[mtch.index]));
}
"label" => {
matches.sort_by_key(|mtch| haystack[mtch.index_in_haystack].label.clone());
matches.sort_by(|a, b| {
let label_a = &haystack[a.index_in_haystack].label;
let label_b = &haystack[b.index_in_haystack].label;

// Put anything with an underscore at the end
match (label_a.starts_with('_'), label_b.starts_with('_')) {
(true, false) => std::cmp::Ordering::Greater,
(false, true) => std::cmp::Ordering::Less,
_ => label_a.cmp(label_b),
}
});
}
_ => {}
}
Expand Down

0 comments on commit 210f21f

Please sign in to comment.