diff options
author | Pascal Kuthe | 2022-10-06 23:44:53 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-10-21 01:03:00 +0000 |
commit | 8673c1ec0cb4074a1082d4681b655110d5b7facb (patch) | |
tree | b4f3f442d836466a6f609b994a7b4b1bfb81ac86 /helix-term/src/ui | |
parent | ce399471f047c241c63caba11ce154776df5024c (diff) |
sort codeaction by their kind instead of alphabetically
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r-- | helix-term/src/ui/completion.rs | 2 | ||||
-rw-r--r-- | helix-term/src/ui/menu.rs | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index 7348dcf4..2e555e4b 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -97,7 +97,7 @@ impl Completion { start_offset: usize, trigger_offset: usize, ) -> Self { - let menu = Menu::new(items, (), move |editor: &mut Editor, item, event| { + let menu = Menu::new(items, true, (), move |editor: &mut Editor, item, event| { fn item_to_transaction( doc: &Document, item: &CompletionItem, diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index f77f5e80..b60e6454 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -74,6 +74,7 @@ impl<T: Item> Menu<T> { // rendering) pub fn new( options: Vec<T>, + sort: bool, editor_data: <T as Item>::Data, callback_fn: impl Fn(&mut Editor, Option<&T>, MenuEvent) + 'static, ) -> Self { @@ -91,8 +92,12 @@ impl<T: Item> Menu<T> { recalculate: true, }; - // TODO: scoring on empty input should just use a fastpath - menu.score(""); + if sort { + // TODO: scoring on empty input should just use a fastpath + menu.score(""); + } else { + menu.matches = (0..menu.options.len()).map(|i| (i, 0)).collect(); + } menu } |