MCPcopy Create free account
hub / github.com/cogentcore/core / MatchPrecedence

Function MatchPrecedence

parse/complete/complete.go:183–192  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

181// is assumed to already match the seed by [IsSeedMatching]. A
182// lower return value indicates a higher precedence.
183func 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.

Callers 2

MatchSeedStringFunction · 0.85
MatchSeedCompletionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected