@@ -92,11 +92,15 @@ impl Completion {
93 pub fn new(
93 pub fn new(
94 editor: &Editor,
94 editor: &Editor,
95− items: Vec<CompletionItem>,
95+ mut items: Vec<CompletionItem>,
96 offset_encoding: helix_lsp::OffsetEncoding,
96 offset_encoding: helix_lsp::OffsetEncoding,
97 start_offset: usize,
97 start_offset: usize,
98 trigger_offset: usize,
98 trigger_offset: usize,
99 ) -> Self {
99 ) -> Self {
100+ // Sort completion items according to their preselect status (given by the LSP server)
101+ items.sort_by_key(|item| !item.preselect.unwrap_or(false));
103+ // Then create the menu
100 let menu = Menu::new(items, (), move |editor: &mut Editor, item, event| {
104 let menu = Menu::new(items, (), move |editor: &mut Editor, item, event| {
101 fn item_to_transaction(
105 fn item_to_transaction(
102 doc: &Document,
106 doc: &Document,