m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-16 23:33:39 -05:00

Ignore leading whitespaces when calculating 'begin' index

This commit is contained in:
Junegunn Choi
2016-01-14 01:32:03 +09:00
parent 23244bb410
commit 45143f9541
3 changed files with 68 additions and 2 deletions

View File

@@ -92,7 +92,14 @@ func (item *Item) Rank(cache bool) [5]int32 {
}
case byBegin:
// We can't just look at item.offsets[0][0] because it can be an inverse term
val = int32(minBegin)
whitePrefixLen := 0
for idx, r := range item.text {
whitePrefixLen = idx
if idx == minBegin || r != ' ' && r != '\t' {
break
}
}
val = int32(minBegin - whitePrefixLen)
case byEnd:
if prevEnd > 0 {
val = int32(1 + len(item.text) - prevEnd)