769
return undefined;
770
}
772
>
row--;
773
>
column--;
774
>
775
>
const result: FuzzyScore = [_table[row][column], wordStart];
776
>
777
>
let backwardsDiagLength = 0;
778
>
let maxMatchColumn = 0;
779
>
780
>
while (row >= 1) {
781
>
// Find the column where we go diagonally up
782
>
let diagColumn = column;
783
>
do {
784
>
const arrow = _arrows[row][diagColumn];
785
>
if (arrow === Arrow.LeftLeft) {
786
diagColumn = diagColumn - 2;
787
>
} else if (arrow === Arrow.Left) {
filters.ts
788
diagColumn = diagColumn - 1;
790
>
// found the diagonal
791
>
break;
792
>
}
793
>
} while (diagColumn >= 1);
794
>
795
>
// Overturn the "forwards" decision if keeping the "backwards" diagonal would give a better match
796
>
if (
797
>
backwardsDiagLength > 1 // only if we would have a contiguous match of 3 characters
798
&& patternLow[patternStart + row - 1] === wordLow[wordStart + column - 1] // only if we can do a contiguous match diagonally
799
&& !isUpperCaseAtPos(diagColumn + wordStart - 1, word, wordLow) // only if the forwards chose diagonal is not an uppercase
800
&& backwardsDiagLength + 1 > _diag[row][diagColumn] // only if our contiguous match would be longer than the "forwards" contiguous match
802
diagColumn = column;
803
}
805
>
if (diagColumn === column) {
806
// this is a contiguous match
807
backwardsDiagLength++;
809
backwardsDiagLength = 1;
810
}
812
>
if (!maxMatchColumn) {
813
>
// remember the last matched column
814
>
maxMatchColumn = diagColumn;
815
>
}
816
>
817
>
row--;
818
>
column = diagColumn - 1;
819
>
result.push(column);
820
>
}
821
>
822
if (wordLen - wordStart === patternLen && options.boostFullMatch) {
823
// the word matches the pattern with all characters!