Do not exclude 1 char gap

This commit is contained in:
KatieFrogs 2022-02-28 03:24:14 +03:00
parent 8c3429b67c
commit 03428aa50e

View File

@ -3058,15 +3058,22 @@ class SongSelect{
var score0 = a[0].score
a[0].ranges = this.indexesToRanges(a[0].indexes)
if(a[0].indexes.length > 1){
if(a[0].ranges.length > a[0].indexes.length / 2){
var index = a[0].target.indexOf(query)
if(index === -1){
score0 = -Infinity
a[0].ranges = null
}else{
a[0].ranges = [[index, index + query.length - 1]]
var rangeAmount = a[0].ranges.length
var lastIdx = -3
a[0].ranges.forEach(range => {
if(range[0] - lastIdx <= 2){
rangeAmount--
score0 -= 1000
}
}else if(a[0].ranges.length !== 1){
lastIdx = range[1]
})
var index = a[0].target.indexOf(query)
if(index !== -1){
a[0].ranges = [[index, index + query.length - 1]]
}else if(rangeAmount > a[0].indexes.length / 2){
score0 = -Infinity
a[0].ranges = null
}else if(rangeAmount !== 1){
score0 -= 9000
}
}
@ -3075,15 +3082,22 @@ class SongSelect{
var score1 = a[1].score - 1000
a[1].ranges = this.indexesToRanges(a[1].indexes)
if(a[1].indexes.length > 1){
if(a[1].ranges.length > a[1].indexes.length / 2){
var index = a[1].target.indexOf(query)
if(index === -1){
score1 = -Infinity
a[1].ranges = null
}else{
a[1].ranges = [[index, index + query.length - 1]]
var rangeAmount = a[1].ranges.length
var lastIdx = -3
a[1].ranges.forEach(range => {
if(range[0] - lastIdx <= 2){
rangeAmount--
score1 -= 1000
}
}else if(a[1].ranges.length !== 1){
lastIdx = range[1]
})
var index = a[1].target.indexOf(query)
if(index !== -1){
a[1].ranges = [[index, index + query.length - 1]]
}else if(rangeAmount > a[1].indexes.length / 2){
score1 = -Infinity
a[1].ranges = null
}else if(rangeAmount !== 1){
score1 -= 9000
}
}