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

Fix panic on inverse match query with --tiebreak=chunk

Fix #3055
This commit is contained in:
Junegunn Choi
2022-11-18 16:18:11 +09:00
parent 3da63f394d
commit 1bebd6f4f5
3 changed files with 20 additions and 11 deletions

View File

@@ -50,20 +50,21 @@ func buildResult(item *Item, offsets []Offset, score int) Result {
// Higher is better
val = math.MaxUint16 - util.AsUint16(score)
case byChunk:
b := minBegin
e := maxEnd
l := item.text.Length()
for ; b >= 1; b-- {
if unicode.IsSpace(item.text.Get(b - 1)) {
break
if validOffsetFound {
b := minBegin
e := maxEnd
for ; b >= 1; b-- {
if unicode.IsSpace(item.text.Get(b - 1)) {
break
}
}
}
for ; e < l; e++ {
if unicode.IsSpace(item.text.Get(e)) {
break
for ; e < numChars; e++ {
if unicode.IsSpace(item.text.Get(e)) {
break
}
}
val = util.AsUint16(e - b)
}
val = util.AsUint16(e - b)
case byLength:
val = item.TrimLength()
case byBegin, byEnd: