Skip to content
Open
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
1 change: 1 addition & 0 deletions completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
type Suggest struct {
Text string
Description string
AlsoMatch []string
}

// CompletionManager manages which suggestion is now selected.
Expand Down
16 changes: 10 additions & 6 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ func filterSuggestions(suggestions []Suggest, sub string, ignoreCase bool, funct

ret := make([]Suggest, 0, len(suggestions))
for i := range suggestions {
c := suggestions[i].Text
if ignoreCase {
c = strings.ToUpper(c)
}
if function(c, sub) {
ret = append(ret, suggestions[i])
possibleMatches := append(suggestions[i].AlsoMatch, suggestions[i].Text)
for _, possibleMatch := range possibleMatches {
c := possibleMatch
if ignoreCase {
c = strings.ToUpper(c)
}
if function(c, sub) {
ret = append(ret, suggestions[i])
break
}
}
}
return ret
Expand Down