1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-22 06:09:25 -05:00

feat(cli/lsp): Sort repl completions (#15171)

This commit is contained in:
2shiori17 2022-07-13 11:21:56 +09:00 committed by GitHub
parent 3a4e95c431
commit 61340f1d89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,11 +145,18 @@ impl ReplLanguageServer {
.ok() .ok()
.unwrap_or_default(); .unwrap_or_default();
let items = match response { let mut items = match response {
Some(CompletionResponse::Array(items)) => items, Some(CompletionResponse::Array(items)) => items,
Some(CompletionResponse::List(list)) => list.items, Some(CompletionResponse::List(list)) => list.items,
None => Vec::new(), None => Vec::new(),
}; };
items.sort_by_key(|item| {
if let Some(sort_text) = &item.sort_text {
sort_text.clone()
} else {
item.label.clone()
}
});
items items
.into_iter() .into_iter()
.filter_map(|item| { .filter_map(|item| {