Skip to content

Commit

Permalink
Fix unexpected result of --tiebreak=end
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed Dec 26, 2023
1 parent 97ccef1 commit 519de7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/test_go.rb
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,12 @@ def test_tiebreak_end
'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
Expand Down

0 comments on commit 519de7c

Please sign in to comment.