fix comp complete

This commit is contained in:
sawka 2022-11-22 00:32:27 -08:00
parent bd3595c954
commit 00356fc297
2 changed files with 10 additions and 1 deletions

View File

@ -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 {

View File

@ -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)