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

Function MatchSeedString

parse/complete/complete.go:103–121  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

101// transformations of each possible completion contain a lowercase
102// version of the seed. It returns nil if there are no matches.
103func 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

Callers 2

fileCompleteMethod · 0.92
TestMatchSeedStringFunction · 0.85

Calls 3

IsSeedMatchingFunction · 0.85
MatchPrecedenceFunction · 0.85
CompareMethod · 0.45

Tested by 1

TestMatchSeedStringFunction · 0.68