Skip to content

Commit

Permalink
feat(cli/lsp): Sort repl completions (#15171)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoseio authored Jul 13, 2022
1 parent 3a4e95c commit 61340f1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cli/lsp/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,18 @@ impl ReplLanguageServer {
.ok()
.unwrap_or_default();

let items = match response {
let mut items = match response {
Some(CompletionResponse::Array(items)) => items,
Some(CompletionResponse::List(list)) => list.items,
None => Vec::new(),
};
items.sort_by_key(|item| {
if let Some(sort_text) = &item.sort_text {
sort_text.clone()
} else {
item.label.clone()
}
});
items
.into_iter()
.filter_map(|item| {
Expand Down

0 comments on commit 61340f1

Please sign in to comment.