-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Improve sorting for inline menu (codeaction + completion) #4134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6b16b9d
63a54ee
a36bb1d
f813ccc
3f4296b
2feba44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,24 +77,20 @@ impl<T: Item> Menu<T> { | |
editor_data: <T as Item>::Data, | ||
callback_fn: impl Fn(&mut Editor, Option<&T>, MenuEvent) + 'static, | ||
) -> Self { | ||
let mut menu = Self { | ||
let matches = (0..options.len()).map(|i| (i, 0)).collect(); | ||
Self { | ||
options, | ||
editor_data, | ||
matcher: Box::new(Matcher::default()), | ||
matches: Vec::new(), | ||
matches, | ||
cursor: None, | ||
widths: Vec::new(), | ||
callback_fn: Box::new(callback_fn), | ||
scroll: 0, | ||
size: (0, 0), | ||
viewport: (0, 0), | ||
recalculate: true, | ||
}; | ||
|
||
// TODO: scoring on empty input should just use a fastpath | ||
menu.score(""); | ||
|
||
menu | ||
} | ||
} | ||
|
||
pub fn score(&mut self, pattern: &str) { | ||
|
@@ -112,10 +108,7 @@ impl<T: Item> Menu<T> { | |
.map(|score| (index, score)) | ||
}), | ||
); | ||
// matches.sort_unstable_by_key(|(_, score)| -score); | ||
self.matches.sort_unstable_by_key(|(index, _score)| { | ||
self.options[*index].sort_text(&self.editor_data) | ||
}); | ||
Comment on lines
-115
to
-118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this change impact other menus now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The inline menu is only used for codeactions and autocompletions as far as I found. For auto-completions sorting by fuzzy match is more desirable and infarct exactly #3215. I have also updated the PR description and PR title a while ago to reflect that this changes the behaviour of all inline menus:
|
||
self.matches.sort_unstable_by_key(|(_, score)| -score); | ||
|
||
// reset cursor position | ||
self.cursor = None; | ||
|
Uh oh!
There was an error while loading. Please reload this page.