multiple possible matches
This commit is contained in:
parent
422a0f0d6a
commit
25448a21d9
@ -25,6 +25,7 @@ var (
|
|||||||
type Suggest struct {
|
type Suggest struct {
|
||||||
Text string
|
Text string
|
||||||
Description string
|
Description string
|
||||||
|
AlsoMatch []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompletionManager manages which suggestion is now selected.
|
// CompletionManager manages which suggestion is now selected.
|
||||||
|
16
filter.go
16
filter.go
@ -59,12 +59,16 @@ func filterSuggestions(suggestions []Suggest, sub string, ignoreCase bool, funct
|
|||||||
|
|
||||||
ret := make([]Suggest, 0, len(suggestions))
|
ret := make([]Suggest, 0, len(suggestions))
|
||||||
for i := range suggestions {
|
for i := range suggestions {
|
||||||
c := suggestions[i].Text
|
possibleMatches := append(suggestions[i].AlsoMatch, suggestions[i].Text)
|
||||||
if ignoreCase {
|
for _, possibleMatch := range possibleMatches {
|
||||||
c = strings.ToUpper(c)
|
c := possibleMatch
|
||||||
}
|
if ignoreCase {
|
||||||
if function(c, sub) {
|
c = strings.ToUpper(c)
|
||||||
ret = append(ret, suggestions[i])
|
}
|
||||||
|
if function(c, sub) {
|
||||||
|
ret = append(ret, suggestions[i])
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user