junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.52k stars 2.41k forks source link

[Feature Request] fuzzy match not just letter deletions but also letter substitutions, nearest-neighbour letter interchanges #2848

Closed justpeanuts closed 2 years ago

justpeanuts commented 2 years ago

Info

Problem / Steps to reproduce

Problem:

My main use of a "fuzzy" search program is to match results regardless of typos in the query. At this point fzf only works for query typos that involve letter deletions (eg. fiefox instead of firefox)... it does not work when a letter is wrongly substituted for another letter (eg. firdfox instead of firefox) or when nearest-neighbour letter interchanges are involved (eg. fierfox instead of firefox). IMHO i think the "fuzzy searching" should include substitutions and interchanges in addition to deletions for the fuzzy searching to be truly fuzzy and dependable.

Steps to reproduce:

execute: echo -e "open firefox \n firefox search " | fzf

Results

fiefox matches correctly with firefox firdfox does not match with firefox (expected to fuzzy match) fierfox does not match with firefox (expected to fuzzy match)

justpeanuts commented 2 years ago

Found this so i am closing the issue: https://github.com/junegunn/fzf/issues/2272#issuecomment-736175232

any chance to let fzf consider the levenshtein distance? or/and give words with many letter matches a higher weight than scattered matches?

Thanks for the suggestion, but it's not going to happen. fzf is highly optimized for the current search/ranking algorithm and I'm not interested in adding, optimizing, and maintaining a different algorithm which is an awful lot of work.

But if anyone knows how to (easily) implement fuzzy search as described above, please let me know!