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:
parent
3a4e95c431
commit
61340f1d89
1 changed files with 8 additions and 1 deletions
|
@ -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| {
|
||||||
|
|
Loading…
Add table
Reference in a new issue