MatchSeedString returns a list of matches given a list of string possibilities and a seed. It checks whether different transformations of each possible completion contain a lowercase version of the seed. It returns nil if there are no matches.
(completions []string, seed string)
| 101 | // transformations of each possible completion contain a lowercase |
| 102 | // version of the seed. It returns nil if there are no matches. |
| 103 | func MatchSeedString(completions []string, seed string) []string { |
| 104 | if len(seed) == 0 { |
| 105 | // everything matches |
| 106 | return completions |
| 107 | } |
| 108 | |
| 109 | var matches []string |
| 110 | lseed := strings.ToLower(seed) |
| 111 | |
| 112 | for _, c := range completions { |
| 113 | if IsSeedMatching(lseed, c) { |
| 114 | matches = append(matches, c) |
| 115 | } |
| 116 | } |
| 117 | slices.SortStableFunc(matches, func(a, b string) int { |
| 118 | return cmp.Compare(MatchPrecedence(lseed, a), MatchPrecedence(lseed, b)) |
| 119 | }) |
| 120 | return matches |
| 121 | } |
| 122 | |
| 123 | // MatchSeedCompletion returns a list of matches given a list of |
| 124 | // [Completion] possibilities and a seed. It checks whether different |