Skip to content
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

Implement fuzzy finder as default filter for Select/MultiSelect #162

Closed
mikaelmello opened this issue Jun 16, 2023 · 3 comments
Closed

Implement fuzzy finder as default filter for Select/MultiSelect #162

mikaelmello opened this issue Jun 16, 2023 · 3 comments

Comments

@mikaelmello
Copy link
Owner

Is your feature request related to a problem? Please describe.

Fuzzy finder is very valuable, and I don't think it'd imply in a significant performance cost at runtime.

@Baarsgaard
Copy link
Contributor

Baarsgaard commented Sep 9, 2023

Hi, I'm taking a stab at this as I really want to make use of it.

I'm running into some decisions I would like your input on.
In order to support a fuzzy filter, it's necessary to sort the list of options.

I could implement a separate function like Filter<'a, &T> which takes the list of options and replaces self.options with the return value.
The issue with this approach would be when and how to handle filter vs the new ranking/matcher function.
Should the list of options be both filtered and ranked or should filter and ranking/matching be mutually exclusive.
If both should apply, which order, filter first?

Alternatively, I would suggest changing the Filter<'a, &T> function signature from:

pub type Filter<'a, T> = &'a dyn Fn(&str, &T, &str, usize) -> bool;

And give full access to the entire list of options

pub type Filter<'a, T> = &'a dyn Fn(&str, &'a Vec<&T>) -> Vec<&'a T>;

// Alternatively mut ref
pub type Filter<'a, T> = &'a dyn Fn(&str, &'a mut Vec<&T>);

This would allow users to implement whatever filter/ordering logic they want, as well as allowing the use of a default fuzzy filter.

Lastly, it would be simple to add a feature flag enabling the fuzzy vs contains default filter that is currently in place allowing users to exclude the fuzzy_matcher library.
Or implement it using a different library if they feel like it.

@Baarsgaard
Copy link
Contributor

Since #176 is merged, could this be closed?

@mikaelmello
Copy link
Owner Author

Yes, thanks! I'll work over wrapping-up everything that's been merged into a release

@github-project-automation github-project-automation bot moved this from Wanted to Done in Road to v1 Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants