mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-17 21:43:50 -07:00
Fix unexpected result of --tiebreak=end
See https://github.com/junegunn/fzf/issues/3255#issuecomment-1869580320
This commit is contained in:
@@ -80,7 +80,7 @@ func buildResult(item *Item, offsets []Offset, score int) Result {
|
|||||||
if criterion == byBegin {
|
if criterion == byBegin {
|
||||||
val = util.AsUint16(minEnd - whitePrefixLen)
|
val = util.AsUint16(minEnd - whitePrefixLen)
|
||||||
} else {
|
} 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -741,6 +741,12 @@ class TestGoFZF < TestBase
|
|||||||
'xxoxxxxxxx',
|
'xxoxxxxxxx',
|
||||||
'xoxxxxxxxx'
|
'xoxxxxxxxx'
|
||||||
], `#{FZF} -fo --tiebreak=end,length,begin < #{tempname}`.lines(chomp: true)
|
], `#{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
|
end
|
||||||
|
|
||||||
def test_tiebreak_length_with_nth
|
def test_tiebreak_length_with_nth
|
||||||
|
Reference in New Issue
Block a user