MCPcopy
hub / github.com/x-motemen/gore / completeWord

Method completeWord

complete.go:9–27  ·  view source on GitHub ↗
(line string, pos int)

Source from the content-addressed store, hash-verified

7)
8
9func (s *Session) completeWord(line string, pos int) (string, []string, string) {
10 prefix, suffix := line[:pos], line[pos:]
11
12 if strings.TrimSpace(prefix) == "" {
13 return prefix, []string{indent}, suffix
14 }
15
16 if strings.HasPrefix(strings.TrimSpace(prefix), ":") {
17 return s.completeCommand(prefix, suffix)
18 }
19
20 pos, candidates, err := s.completeCode(line, pos, true)
21 if err != nil {
22 errorf("completeCode: %s", err)
23 return "", nil, ""
24 }
25
26 return line[:pos], candidates, ""
27}
28
29func (s *Session) completeCommand(prefix, suffix string) (string, []string, string) {
30 commas, prefix := cutPrefixFunc(prefix, func(c rune) bool {

Callers 3

TestSession_completeWordFunction · 0.95
RunMethod · 0.80

Calls 3

completeCommandMethod · 0.95
completeCodeMethod · 0.95
errorfFunction · 0.85

Tested by 2

TestSession_completeWordFunction · 0.76