diff --git a/public/src/js/songselect.js b/public/src/js/songselect.js index f12d68b..7e0c1be 100644 --- a/public/src/js/songselect.js +++ b/public/src/js/songselect.js @@ -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 } }