diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2015-08-01 23:13:24 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-08-01 23:13:24 +0900 |
| commit | dea60b11bca22f4bf886ae7026bac44521038010 (patch) | |
| tree | af17cedb91520ee1b6a490ea8e22d2cf49818aa8 /src | |
| parent | 5e90f0a57bf21393a12ffc05e022760a71098d92 (diff) | |
| download | fzf-dea60b11bca22f4bf886ae7026bac44521038010.tar.gz | |
Only consider the lengths of the relevant parts when --nth is set
Diffstat (limited to 'src')
| -rw-r--r-- | src/item.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/item.go b/src/item.go index 1eeb1802..68f52972 100644 --- a/src/item.go +++ b/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) |
