diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2016-01-14 01:32:03 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-01-14 01:32:03 +0900 |
commit | 45143f9541d55c5efdadc7ea8acd9474a19eb8c6 (patch) | |
tree | 27868cacf3ac2d9af9a18652f5150636bdbef308 /src | |
parent | 23244bb41087f4f833c33219bba7a7213710ab20 (diff) |
Ignore leading whitespaces when calculating 'begin' index
Diffstat (limited to 'src')
-rw-r--r-- | src/item.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/item.go b/src/item.go index 9200efbf..43ce1a21 100644 --- a/src/item.go +++ b/src/item.go @@ -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) |