Skip to content
Myr

Fix unexpected result of --tiebreak=end

Before adoption: this commit came in with the history the project adopted, so no landing records it.

See https://github.com/junegunn/fzf/issues/3255#issuecomment-1869580320

authored by Junegunn Choi · committed by Junegunn Choi · parent 97ccef1 · Browse files · 2 files+7 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−1 removed

  • tests:+6 added−0 removed
  • other:+1 added−1 removed

2 files+7 added−1 removed

modified:src/result.go+1 added-1 removed
78 unmodified lines
79 }80 if criterion == byBegin {81 val = util.AsUint16(minEnd - whitePrefixLen)82 } else {83 val = util.AsUint16(math.MaxUint16 - math.MaxUint16*(maxEnd-whitePrefixLen)/int(item.TrimLength()))83 val = util.AsUint16(math.MaxUint16 - math.MaxUint16*(maxEnd-whitePrefixLen)/int(item.TrimLength()+1))84 }85 }86 }87 result.points[3-idx] = val
172 unmodified lines
modified:test/test_go.rb+6 added
739 unmodified lines
740 'xxxoxxxxxx',741 'xxoxxxxxxx',742 'xoxxxxxxxx'743 ], `#{FZF} -fo --tiebreak=end,length,begin < #{tempname}`.lines(chomp: true)744745 writelines(tempname, ['/bar/baz', '/foo/bar/baz'])746 assert_equal [747 '/foo/bar/baz',748 '/bar/baz',749 ], `#{FZF} -fbaz --tiebreak=end < #{tempname}`.lines(chomp: true)750 end751752 def test_tiebreak_length_with_nth753 input = %w[
2831 unmodified lines