summaryrefslogtreecommitdiffstats
path: root/src/core.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2022-08-03 22:18:26 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2022-08-03 22:18:26 +0900
commit38259d0382eba18b66c03d62e35089ec10c24698 (patch)
treeecd12308c7bfe674d701480b2a1512acb93a5ca7 /src/core.go
parentf7e7259910393ea3eeeb3ac78913e881d4a86691 (diff)
Fix incorrect ordering of `--tiebreak=chunk`
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core.go b/src/core.go
index 17198f5b..b4bccfbe 100644
--- a/src/core.go
+++ b/src/core.go
@@ -146,18 +146,20 @@ func Run(opts *Options, version string, revision string) {
// Matcher
forward := true
- for _, cri := range opts.Criteria[1:] {
- if cri == byEnd {
+ withPos := false
+ for idx := len(opts.Criteria) - 1; idx > 0; idx-- {
+ switch opts.Criteria[idx] {
+ case byChunk:
+ withPos = true
+ case byEnd:
forward = false
- break
- }
- if cri == byBegin {
- break
+ case byBegin:
+ forward = true
}
}
patternBuilder := func(runes []rune) *Pattern {
return BuildPattern(
- opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward,
+ opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward, withPos,
opts.Filter == nil, opts.Nth, opts.Delimiter, runes)
}
matcher := NewMatcher(patternBuilder, sort, opts.Tac, eventBox)