Improve sorting of completion results (#7727)
This is an attempt to fix #5013 by doing two things: 1. Rank "obvious" matches in completions higher (see the code comment) 2. When tied: rank keywords higher than variables Release Notes: - Improved sorting of completion results to prefer literal matches. ([#5013](https://github.com/zed-industries/zed/issues/5013)). ### Before   ### After   Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: bennetbo <bennetbo@gmx.de>
This commit is contained in:
parent
98fff014da
commit
798c9a7d8b
2 changed files with 49 additions and 7 deletions
|
@ -3441,8 +3441,9 @@ impl Completion {
|
|||
/// them to the user.
|
||||
pub fn sort_key(&self) -> (usize, &str) {
|
||||
let kind_key = match self.lsp_completion.kind {
|
||||
Some(lsp::CompletionItemKind::VARIABLE) => 0,
|
||||
_ => 1,
|
||||
Some(lsp::CompletionItemKind::KEYWORD) => 0,
|
||||
Some(lsp::CompletionItemKind::VARIABLE) => 1,
|
||||
_ => 2,
|
||||
};
|
||||
(kind_key, &self.label.text[self.label.filter_range.clone()])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue