Skip to content
Myr

Use relative position instead of absolute distance for --tiebreak=end

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

Fix unintuitive result where `*fzf*/install` is ranked higher than `fzf/src/fzf/*fzf*-linux_386` on --tiebreak=end.

authored by Junegunn Choi · committed by Junegunn Choi · parent 47b11cb · Browse files · 2 files+7 added−7 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−7 removed

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

2 files+7 added−7 removed

modified:src/result.go+6 added-6 removed
55 unmodified lines
56 val = math.MaxUint16 - util.AsUint16(score)57 case byLength:58 // If offsets is empty, trimLen will be 0, but we don't care59 val = util.AsUint16(trimLen)60 case byBegin:60 case byBegin, byEnd:61 if validOffsetFound {62 whitePrefixLen := 063 for idx := 0; idx < numChars; idx++ {64 r := item.text.Get(idx)
1 unmodified line
66 if idx == minBegin || !unicode.IsSpace(r) {67 break68 }69 }70 if criterion == byBegin {70 val = util.AsUint16(minBegin - whitePrefixLen)71 val = util.AsUint16(minBegin - whitePrefixLen)72 } else {73 val = util.AsUint16(math.MaxUint16 - math.MaxUint16*(maxEnd-whitePrefixLen)/trimLen)74 }75 }72 case byEnd:73 if validOffsetFound {74 val = util.AsUint16(1 + numChars - maxEnd)75 }76 }77 result.rank.points[idx] = val78 }79
162 unmodified lines
modified:test/test_go.rb+1 added-1 removed
602 unmodified lines
603 'xoxxxxxxxx',604 ], `#{FZF} -fo --tiebreak=end < #{tempname}`.split($/)605606 assert_equal [607 ' xxxxoxxx',607 'xxxxxoxxx',608 ' xxxxoxxx',609 'xxxxoxxxx',610 'xxxoxxxxxx',611 'xxoxxxxxxx',612 'xoxxxxxxxx',
943 unmodified lines