mirror of https://github.com/helix-editor/helix
never sort menu items when no fuzzy matching is possible
parent
dc3527f52d
commit
189aa0bfcf
|
@ -490,8 +490,7 @@ pub fn code_action(cx: &mut Context) {
|
||||||
_ => 7,
|
_ => 7,
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut picker =
|
let mut picker = ui::Menu::new(actions, (), move |editor, code_action, event| {
|
||||||
ui::Menu::new(actions, false, (), move |editor, code_action, event| {
|
|
||||||
if event != PromptEvent::Validate {
|
if event != PromptEvent::Validate {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ impl Completion {
|
||||||
start_offset: usize,
|
start_offset: usize,
|
||||||
trigger_offset: usize,
|
trigger_offset: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let menu = Menu::new(items, true, (), move |editor: &mut Editor, item, event| {
|
let menu = Menu::new(items, (), move |editor: &mut Editor, item, event| {
|
||||||
fn item_to_transaction(
|
fn item_to_transaction(
|
||||||
doc: &Document,
|
doc: &Document,
|
||||||
item: &CompletionItem,
|
item: &CompletionItem,
|
||||||
|
|
|
@ -74,15 +74,15 @@ impl<T: Item> Menu<T> {
|
||||||
// rendering)
|
// rendering)
|
||||||
pub fn new(
|
pub fn new(
|
||||||
options: Vec<T>,
|
options: Vec<T>,
|
||||||
sort: bool,
|
|
||||||
editor_data: <T as Item>::Data,
|
editor_data: <T as Item>::Data,
|
||||||
callback_fn: impl Fn(&mut Editor, Option<&T>, MenuEvent) + 'static,
|
callback_fn: impl Fn(&mut Editor, Option<&T>, MenuEvent) + 'static,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut menu = Self {
|
let matches = (0..options.len()).map(|i| (i, 0)).collect();
|
||||||
|
Self {
|
||||||
options,
|
options,
|
||||||
editor_data,
|
editor_data,
|
||||||
matcher: Box::new(Matcher::default()),
|
matcher: Box::new(Matcher::default()),
|
||||||
matches: Vec::new(),
|
matches,
|
||||||
cursor: None,
|
cursor: None,
|
||||||
widths: Vec::new(),
|
widths: Vec::new(),
|
||||||
callback_fn: Box::new(callback_fn),
|
callback_fn: Box::new(callback_fn),
|
||||||
|
@ -90,16 +90,7 @@ impl<T: Item> Menu<T> {
|
||||||
size: (0, 0),
|
size: (0, 0),
|
||||||
viewport: (0, 0),
|
viewport: (0, 0),
|
||||||
recalculate: true,
|
recalculate: true,
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn score(&mut self, pattern: &str) {
|
pub fn score(&mut self, pattern: &str) {
|
||||||
|
|
Loading…
Reference in New Issue