mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-19 12:12:42 +02:00
Rename FuzzySearch to FilterStrings
It isn't necessarily fuzzy any more.
This commit is contained in:
parent
a8797c7261
commit
561afa9901
@ -83,7 +83,7 @@ func (self *SuggestionsHelper) GetBranchNameSuggestionsFunc() func(string) []*ty
|
|||||||
if input == "" {
|
if input == "" {
|
||||||
matchingBranchNames = branchNames
|
matchingBranchNames = branchNames
|
||||||
} else {
|
} 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 {
|
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
|
// doing another fuzzy search for good measure
|
||||||
matchingNames = utils.FuzzySearch(input, matchingNames, true)
|
matchingNames = utils.FilterStrings(input, matchingNames, true)
|
||||||
} else {
|
} else {
|
||||||
substrings := strings.Fields(input)
|
substrings := strings.Fields(input)
|
||||||
_ = self.c.Model().FilesTrie.Visit(func(prefix patricia.Prefix, item patricia.Item) error {
|
_ = 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 == "" {
|
if input == "" {
|
||||||
matches = options
|
matches = options
|
||||||
} else {
|
} else {
|
||||||
matches = utils.FuzzySearch(input, options, useFuzzySearch)
|
matches = utils.FilterStrings(input, options, useFuzzySearch)
|
||||||
}
|
}
|
||||||
|
|
||||||
return matchesToSuggestions(matches)
|
return matchesToSuggestions(matches)
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FuzzySearch(needle string, haystack []string, useFuzzySearch bool) []string {
|
func FilterStrings(needle string, haystack []string, useFuzzySearch bool) []string {
|
||||||
if needle == "" {
|
if needle == "" {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestFuzzySearch is a function.
|
func TestFilterStrings(t *testing.T) {
|
||||||
func TestFuzzySearch(t *testing.T) {
|
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
needle string
|
needle string
|
||||||
haystack []string
|
haystack []string
|
||||||
@ -68,7 +67,7 @@ func TestFuzzySearch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user