diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-26 23:40:20 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-26 23:42:14 +0900 |
commit | 519de7c833ae46db72538b3cb5d2a53e08be2d78 (patch) | |
tree | dc2ad75e743da90ebd61337a6d25b72823cb0132 | |
parent | 97ccef1a04ef8a3fcffcc6682765d651b86d0480 (diff) |
Fix unexpected result of --tiebreak=end
See https://github.com/junegunn/fzf/issues/3255#issuecomment-1869580320
-rw-r--r-- | src/result.go | 2 | ||||
-rwxr-xr-x | test/test_go.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/result.go b/src/result.go index 1212cabe..d72de420 100644 --- a/src/result.go +++ b/src/result.go @@ -80,7 +80,7 @@ func buildResult(item *Item, offsets []Offset, score int) Result { if criterion == byBegin { val = util.AsUint16(minEnd - whitePrefixLen) } else { - val = util.AsUint16(math.MaxUint16 - math.MaxUint16*(maxEnd-whitePrefixLen)/int(item.TrimLength())) + val = util.AsUint16(math.MaxUint16 - math.MaxUint16*(maxEnd-whitePrefixLen)/int(item.TrimLength()+1)) } } } diff --git a/test/test_go.rb b/test/test_go.rb index 771064ee..7b1f70a8 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -741,6 +741,12 @@ class TestGoFZF < TestBase 'xxoxxxxxxx', 'xoxxxxxxxx' ], `#{FZF} -fo --tiebreak=end,length,begin < #{tempname}`.lines(chomp: true) + + writelines(tempname, ['/bar/baz', '/foo/bar/baz']) + assert_equal [ + '/foo/bar/baz', + '/bar/baz', + ], `#{FZF} -fbaz --tiebreak=end < #{tempname}`.lines(chomp: true) end def test_tiebreak_length_with_nth |