MatchPrecedence returns the sorting precedence of the given completion relative to the given lowercase seed. The completion is assumed to already match the seed by [IsSeedMatching]. A lower return value indicates a higher precedence.
(lseed string, completion string)
| 181 | // is assumed to already match the seed by [IsSeedMatching]. A |
| 182 | // lower return value indicates a higher precedence. |
| 183 | func MatchPrecedence(lseed string, completion string) int { |
| 184 | lc := strings.ToLower(completion) |
| 185 | if strings.HasPrefix(lc, lseed) { |
| 186 | return 0 |
| 187 | } |
| 188 | if len(lseed) > 0 && strings.HasPrefix(lc, lseed[:1]) { |
| 189 | return 1 |
| 190 | } |
| 191 | return 2 |
| 192 | } |
| 193 | |
| 194 | // SeedSpace returns the text after the last whitespace, |
| 195 | // which is typically used for creating a completion seed string. |
no outgoing calls
no test coverage detected