From 38259d0382eba18b66c03d62e35089ec10c24698 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 3 Aug 2022 22:18:26 +0900 Subject: Fix incorrect ordering of `--tiebreak=chunk` --- src/core.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/core.go') 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) -- cgit v1.2.3