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

Fixing search results #863

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/krew/cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ type searchItem struct {
type searchCorpus []searchItem

func (s searchCorpus) descriptions() []string {
var res = make([]string, len(s))
res := make([]string, 0, len(s))
for _, corpus := range s {
res = append(res, corpus.description)
}
return res
}

func (s searchCorpus) names() []string {
var res = make([]string, len(s))
res := make([]string, 0, len(s))
for _, corpus := range s {
res = append(res, corpus.name)
}
Expand Down
10 changes: 10 additions & 0 deletions cmd/krew/cmd/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func Test_searchByNameAndDesc(t *testing.T) {
},
expected: []string{"baz"},
},
{
keyword: "",
names: []string{"plugin1", "plugin2", "plugin3"}, // empty keyword, only names match
descs: []string{
"Description for plugin1",
"Description for plugin2",
"Description for plugin3",
},
expected: []string{"plugin1", "plugin2", "plugin3"},
},
}

for _, tp := range testPlugins {
Expand Down
Loading