1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-04 22:34:39 +02:00

Rename FuzzySearch to FilterStrings

It isn't necessarily fuzzy any more.
This commit is contained in:
Stefan Haller 2024-03-17 09:11:00 +01:00
parent a8797c7261
commit 561afa9901
3 changed files with 6 additions and 7 deletions

View File

@ -83,7 +83,7 @@ func (self *SuggestionsHelper) GetBranchNameSuggestionsFunc() func(string) []*ty
if input == "" {
matchingBranchNames = branchNames
} else {
matchingBranchNames = utils.FuzzySearch(input, branchNames, self.c.UserConfig.Gui.UseFuzzySearch())
matchingBranchNames = utils.FilterStrings(input, branchNames, self.c.UserConfig.Gui.UseFuzzySearch())
}
return lo.Map(matchingBranchNames, func(branchName string, _ int) *types.Suggestion {
@ -136,7 +136,7 @@ func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*type
})
// doing another fuzzy search for good measure
matchingNames = utils.FuzzySearch(input, matchingNames, true)
matchingNames = utils.FilterStrings(input, matchingNames, true)
} else {
substrings := strings.Fields(input)
_ = self.c.Model().FilesTrie.Visit(func(prefix patricia.Prefix, item patricia.Item) error {
@ -205,7 +205,7 @@ func FuzzySearchFunc(options []string, useFuzzySearch bool) func(string) []*type
if input == "" {
matches = options
} else {
matches = utils.FuzzySearch(input, options, useFuzzySearch)
matches = utils.FilterStrings(input, options, useFuzzySearch)
}
return matchesToSuggestions(matches)

View File

@ -7,7 +7,7 @@ import (
"github.com/samber/lo"
)
func FuzzySearch(needle string, haystack []string, useFuzzySearch bool) []string {
func FilterStrings(needle string, haystack []string, useFuzzySearch bool) []string {
if needle == "" {
return []string{}
}

View File

@ -7,8 +7,7 @@ import (
"github.com/stretchr/testify/assert"
)
// TestFuzzySearch is a function.
func TestFuzzySearch(t *testing.T) {
func TestFilterStrings(t *testing.T) {
type scenario struct {
needle string
haystack []string
@ -68,7 +67,7 @@ func TestFuzzySearch(t *testing.T) {
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, FuzzySearch(s.needle, s.haystack, s.useFuzzySearch))
assert.EqualValues(t, s.expected, FilterStrings(s.needle, s.haystack, s.useFuzzySearch))
}
}