diff --git a/pkg/comp/comp.go b/pkg/comp/comp.go index 445ee53d..9531479b 100644 --- a/pkg/comp/comp.go +++ b/pkg/comp/comp.go @@ -319,7 +319,7 @@ func computeCompExtension(compPrefix string, crtn *CompReturn) (string, bool) { if lcp == compPrefix || len(lcp) < len(compPrefix) || !strings.HasPrefix(lcp, compPrefix) { return "", false } - return lcp[len(compPrefix):], utilfn.ContainsStr(compStrs, lcp) + return lcp[len(compPrefix):], (utilfn.ContainsStr(compStrs, lcp) && !utilfn.IsPrefix(compStrs, lcp)) } func (p *CompPoint) FullyExtend(crtn *CompReturn) utilfn.StrWithPos { diff --git a/pkg/utilfn/utilfn.go b/pkg/utilfn/utilfn.go index 752684d9..e5b245f2 100644 --- a/pkg/utilfn/utilfn.go +++ b/pkg/utilfn/utilfn.go @@ -120,6 +120,15 @@ func ContainsStr(strs []string, test string) bool { return false } +func IsPrefix(strs []string, test string) bool { + for _, s := range strs { + if len(s) > len(test) && strings.HasPrefix(s, test) { + return true + } + } + return false +} + type StrWithPos struct { Str string Pos int // this is a 'rune' position (not a byte position)