This commit is contained in:
Johannes Rieken 2019-08-21 11:14:25 +02:00
parent 7621355f7e
commit acb6d62091
2 changed files with 10 additions and 1 deletions

View file

@ -549,7 +549,7 @@ export function fuzzyScore(pattern: string, patternLow: string, patternPos: numb
const patternStartPos = patternPos;
const wordStartPos = wordPos;
// There will be a mach, fill in tables
// There will be a match, fill in tables
for (patternPos = patternStartPos + 1; patternPos <= patternLen; patternPos++) {
for (wordPos = 1; wordPos <= wordLen; wordPos++) {
@ -573,6 +573,11 @@ export function fuzzyScore(pattern: string, patternLow: string, patternPos: numb
} else {
score = 5;
}
} else if (isSeparatorAtPos(wordLow, wordPos - 1) && (wordPos === 1 || !isSeparatorAtPos(wordLow, wordPos - 2))) {
// hitting a separator: `. <-> foo.bar`
// ^
score = 5;
} else if (isSeparatorAtPos(wordLow, wordPos - 2) || isWhitespaceAtPos(wordLow, wordPos - 2)) {
// post separator: `foo <-> bar_foo`
// ^^^

View file

@ -366,6 +366,10 @@ suite('Filters', () => {
assertMatches('f', ':foo', ':^foo', fuzzyScore);
});
test('Separator only match should not be weak #79558', function () {
assertMatches('.', 'foo.bar', 'foo^.bar', fuzzyScore);
});
test('Cannot set property \'1\' of undefined, #26511', function () {
let word = new Array<void>(123).join('a');
let pattern = new Array<void>(120).join('a');