ags icon indicating copy to clipboard operation
ags copied to clipboard

Feature Request: Fuzzy querying for the applications service

Open SystematicError opened this issue 1 year ago • 4 comments

Judging the source code for the Applications service, it looks like currently its querying for an exact substring using .match(). Having a fuzzy string matching algorithm instead would improve the user experience in interfaces like application launchers.

If implementing from scratch, one simple viable algorithm for this purpose is the Levenshtein distance algorithm.

SystematicError avatar Jan 15 '24 18:01 SystematicError

I don't think I am skilled enough to implement fuzzy matching myself. There is this fzf npm package, we could use that I know works with gjs. It wouldn't be an issue with nix, but I don't know if I want to include an npm build step, not sure how other package managers work. I'll try to read through it and only include the parts we need

Aylur avatar Jan 15 '24 19:01 Aylur

had a quick look, its bundled as a single file, so we can easily include it

Aylur avatar Jan 15 '24 19:01 Aylur

this would break the current API with match, as you need to return the match score so that a user can sort according to that. (api doc: https://fzf.netlify.app/docs/latest#api-fzf-find-query). I would propose introducing a new match_fuzzy function, so that one can use either exact matching or fuzzy matching.

If you would be interested in a ready PR i could try to implement that, as i already kind of did that back in my awesome wm setup :)

paulhersch avatar Feb 19 '24 10:02 paulhersch

https://github.com/Aylur/ags/assets/74120050/c19ed421-9030-4c6c-a891-b0f18850450e

gory test with fzy because i could just clone the repo for simplicity

if an apps description is included there are sometimes weird matches, that don't make sense to me. It seems to make more sense when only name and executable are used for matching. Should a user have the ability to specify attributes to match and score on? Otherwise it might be more frustrating for some people to use fuzzy_match.

Edit: fixed embed

paulhersch avatar Feb 23 '24 23:02 paulhersch