diff --git a/src/result.go b/src/result.go index 1212cab..d72de42 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 771064e..7b1f70a 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