summaryrefslogtreecommitdiff
path: root/src/core.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-13 17:37:50 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-13 17:37:50 +0900
commit56fef7c8df2713261fbdbd396aa81ed23d9a945a (patch)
treeb8f8c52f84f7c4a37cca062dcc871e91fc63f160 /src/core.go
parentba0935c71f5507958056201ddad2fc48674a586d (diff)
downloadfzf-56fef7c8df2713261fbdbd396aa81ed23d9a945a.tar.gz
Simplify nth comparison when reusing transformed tokens
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core.go b/src/core.go
index aaf1cf0d..b8851d79 100644
--- a/src/core.go
+++ b/src/core.go
@@ -192,11 +192,12 @@ func Run(opts *Options) (int, error) {
}
nth := opts.Nth
+ nthRevision := 0
patternCache := make(map[string]*Pattern)
patternBuilder := func(runes []rune) *Pattern {
return BuildPattern(cache, patternCache,
opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward, withPos,
- opts.Filter == nil, nth, opts.Delimiter, runes)
+ opts.Filter == nil, nth, opts.Delimiter, nthRevision, runes)
}
inputRevision := revision{}
snapshotRevision := revision{}
@@ -378,6 +379,7 @@ func Run(opts *Options) (int, error) {
if val.nth != nil {
// Change nth and clear caches
nth = *val.nth
+ nthRevision++
patternCache = make(map[string]*Pattern)
cache.Clear()
inputRevision.bumpMinor()