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

Add fuzzy match filter #92

Merged
merged 1 commit into from
Oct 20, 2018
Merged

Add fuzzy match filter #92

merged 1 commit into from
Oct 20, 2018

Conversation

kalafut
Copy link
Contributor

@kalafut kalafut commented Sep 3, 2018

This completion filter is similar to fuzzy-finder search tools, which match as long as all search characters are present and in order. I find it a very effective method for rapidly searching.

I also factored out some repeated code that would otherwise appear in four functions. If you don't like that I can undo that part.

@orisano orisano self-requested a review October 20, 2018 05:59
Copy link
Collaborator

@orisano orisano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -109,3 +138,27 @@ func TestFilter(t *testing.T) {
}
}
}

func TestFuzzy(t *testing.T) {
Copy link
Owner

@c-bata c-bata Oct 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestFuzzyMatch is better to avoid conflict

}

// FilterContains checks whether the completion.Text contains sub.
func FilterContains(completions []Suggest, sub string, ignoreCase bool) []Suggest {
func filterCommon(completions []Suggest, sub string, ignoreCase bool, test func(string, string) bool) []Suggest {
Copy link
Owner

@c-bata c-bata Oct 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think function is better than test, because filter function in python3 also uses function as the argument name.
https://docs.python.org/3.6/library/functions.html#filter

@c-bata
Copy link
Owner

c-bata commented Oct 20, 2018

Suggested algorithm is quite simple. So it may replace with another algorithm in the future (refs #105) but I wanna merge this because it's better than nothing.

@c-bata c-bata changed the base branch from master to fuzzy-filter October 20, 2018 06:46
@c-bata c-bata merged commit dfd47a6 into c-bata:fuzzy-filter Oct 20, 2018
@c-bata
Copy link
Owner

c-bata commented Oct 20, 2018

I will merge this branch into master after fixing the name of variable and function that I commented.

@c-bata c-bata mentioned this pull request Oct 20, 2018
@c-bata
Copy link
Owner

c-bata commented Oct 20, 2018

Merged into master branch.
#106

Thanks 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants