summaryrefslogtreecommitdiffstats
path: root/src/pattern.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-08-08 13:22:30 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-08-08 13:23:33 +0900
commit999d374f0ce609e1a1a747b5d931bcd9250586d5 (patch)
tree32bfd50f35968f2793287c1899677ed01c54ec32 /src/pattern.go
parentb208aa675ec1745af4fa2c2b461ddb2c7367b2e7 (diff)
Fix invalid cache lookups
Diffstat (limited to 'src/pattern.go')
-rw-r--r--src/pattern.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/pattern.go b/src/pattern.go
index 8cb20983..47cabf78 100644
--- a/src/pattern.go
+++ b/src/pattern.go
@@ -10,12 +10,12 @@ import (
// fuzzy
// 'exact
-// ^exact-prefix
-// exact-suffix$
-// !not-fuzzy
-// !'not-exact
-// !^not-exact-prefix
-// !not-exact-suffix$
+// ^prefix-exact
+// suffix-exact$
+// !inverse-exact
+// !'inverse-fuzzy
+// !^inverse-prefix-exact
+// !inverse-suffix-exact$
type termType int
@@ -32,7 +32,6 @@ type term struct {
inv bool
text []rune
caseSensitive bool
- origText []rune
}
type termSet []term
@@ -101,7 +100,7 @@ func BuildPattern(fuzzy bool, fuzzyAlgo algo.Algo, extended bool, caseMode Case,
for idx, term := range termSet {
// If the query contains inverse search terms or OR operators,
// we cannot cache the search scope
- if !cacheable || idx > 0 || term.inv || !fuzzy && term.typ != termExact {
+ if !cacheable || idx > 0 || term.inv || fuzzy && term.typ != termFuzzy || !fuzzy && term.typ != termExact {
cacheable = false
break Loop
}
@@ -153,7 +152,6 @@ func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet
if !caseSensitive {
text = lowerText
}
- origText := []rune(text)
if !fuzzy {
typ = termExact
}
@@ -204,8 +202,7 @@ func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet
typ: typ,
inv: inv,
text: textRunes,
- caseSensitive: caseSensitive,
- origText: origText})
+ caseSensitive: caseSensitive})
switchSet = true
}
}
@@ -236,7 +233,7 @@ func (p *Pattern) CacheKey() string {
cacheableTerms := []string{}
for _, termSet := range p.termSets {
if len(termSet) == 1 && !termSet[0].inv && (p.fuzzy || termSet[0].typ == termExact) {
- cacheableTerms = append(cacheableTerms, string(termSet[0].origText))
+ cacheableTerms = append(cacheableTerms, string(termSet[0].text))
}
}
return strings.Join(cacheableTerms, " ")