diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-01-13 00:13:31 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-01-13 00:13:31 +0900 |
| commit | d83eb2800a09d86e17c0339d86bd1f22f68164a8 (patch) | |
| tree | 0be6b9c97bf9f8434a367fe2996b82f4b4e36f95 /src/core.go | |
| parent | 6f943112a9998d504a5660754f400786e79f80b2 (diff) | |
| download | fzf-d83eb2800a09d86e17c0339d86bd1f22f68164a8.tar.gz | |
Add change-nth action
Example:
# Start with --nth 1, then 2, then 3, then back to the default, 1
echo 'foo foobar foobarbaz' | fzf --bind 'space:change-nth(2|3|)' --nth 1 -q foo
Close #4172
Close #3109
Diffstat (limited to 'src/core.go')
| -rw-r--r-- | src/core.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core.go b/src/core.go index 89f40ceb..35a143fe 100644 --- a/src/core.go +++ b/src/core.go @@ -190,11 +190,13 @@ func Run(opts *Options) (int, error) { forward = true } } + + nth := opts.Nth 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, opts.Nth, opts.Delimiter, runes) + opts.Filter == nil, nth, opts.Delimiter, runes) } inputRevision := revision{} snapshotRevision := revision{} @@ -373,6 +375,12 @@ func Run(opts *Options) (int, error) { command = val.command environ = val.environ changed = val.changed + if val.nth != nil { + // Change nth and clear caches + nth = *val.nth + patternCache = make(map[string]*Pattern) + inputRevision.bumpMajor() + } if command != nil { useSnapshot = val.sync } |
