mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-17 15:53:39 -05:00
Only consider the lengths of the relevant parts when --nth is set
This commit is contained in:
11
src/item.go
11
src/item.go
@@ -63,7 +63,16 @@ func (i *Item) Rank(cache bool) Rank {
|
||||
var tiebreak uint16
|
||||
switch rankTiebreak {
|
||||
case byLength:
|
||||
tiebreak = uint16(len(*i.text))
|
||||
// It is guaranteed that .transformed in not null in normal execution
|
||||
if i.transformed != nil {
|
||||
lenSum := 0
|
||||
for _, token := range *i.transformed {
|
||||
lenSum += len(*token.text)
|
||||
}
|
||||
tiebreak = uint16(lenSum)
|
||||
} else {
|
||||
tiebreak = uint16(len(*i.text))
|
||||
}
|
||||
case byBegin:
|
||||
// We can't just look at i.offsets[0][0] because it can be an inverse term
|
||||
tiebreak = uint16(minBegin)
|
||||
|
||||
Reference in New Issue
Block a user