multiple possible matches

This commit is contained in:
TobiEiss 2019-01-04 11:44:30 +01:00
parent 422a0f0d6a
commit 25448a21d9
2 changed files with 11 additions and 6 deletions

View File

@ -25,6 +25,7 @@ var (
type Suggest struct {
Text string
Description string
AlsoMatch []string
}
// CompletionManager manages which suggestion is now selected.

View File

@ -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