Fix divide by zero error with --tiebreak=end for long items

Fix #3846
This commit is contained in:
Junegunn Choi 2024-06-10 08:24:39 +09:00
parent 9b0e2daf02
commit dfee7af57b
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -81,7 +81,7 @@ func buildResult(item *Item, offsets []Offset, score int) Result {
if criterion == byBegin { if criterion == byBegin {
val = util.AsUint16(minEnd - whitePrefixLen) val = util.AsUint16(minEnd - whitePrefixLen)
} else { } else {
val = util.AsUint16(math.MaxUint16 - math.MaxUint16*(maxEnd-whitePrefixLen)/int(item.TrimLength()+1)) val = util.AsUint16(math.MaxUint16 - math.MaxUint16*(maxEnd-whitePrefixLen)/(int(item.TrimLength())+1))
} }
} }
} }