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

Fix fuzzy search algorithm #5

Open
jamesls opened this issue Nov 5, 2015 · 1 comment
Open

Fix fuzzy search algorithm #5

jamesls opened this issue Nov 5, 2015 · 1 comment
Labels

Comments

@jamesls
Copy link
Member

jamesls commented Nov 5, 2015

Example:

0.746429 dcli                 describe-reserved-instances-listings
0.298566 dcli                 describe-classic-link-instances

describe-classic-link-instances should be higher.

@joguSD
Copy link
Contributor

joguSD commented Aug 24, 2017

I did some testing with this and have something that works but it has edge cases where things that matched before wont match now because it skips the next occurrence for the next occurrence on a boundary.

describe-classic-link-instances
^--^------^---^
1  2      3   4

This completion is currently punished in two ways:

  1. It's skipping to characters that aren't at a 'word' boundary (moves 2,3,4).
  2. It's not matching most of the completion string (15/31 characters)

Compared to:

describe-reserved-instances-listings
^--^------------------------^^
1  2                        34

Completes 30/36. And the jump from 2 -> 3 isn't penalized very much because 3 is at a boundary. So it basically gets to skip two words and most of the string for nearly free.

Where it's possible for dcli to match like this:

describe-classic-link-instances
^--------^-------^----^
1        2       3    4

In this case you complete more of the word and the moves are to word boundaries (specifically the next word boundary) which isn't penalized as much. We would need to add some prioritization for the next occurrence of the character vs the next occurrence of the character at a boundary or test both and choose the 'better' completion score.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants