Skip to content

Commit be07c3c

Browse files
committed
boost fully covered matches, microsoft#41060
Comparing `const` with `constructor` and `const` should favor the latter. Even tho both are prefix matches, the latter is a perfect match and that should be accounted for.
1 parent 08d824f commit be07c3c

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/vs/base/common/filters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ export function fuzzyScore(pattern: string, word: string, patternMaxWhitespaceIg
576576
_matchesCount = 0;
577577
_topScore = -100;
578578
_patternStartPos = patternStartPos;
579-
_findAllMatches(patternLen, wordLen, 0, new LazyArray(), false);
579+
_findAllMatches(patternLen, wordLen, patternLen === wordLen ? 1 : 0, new LazyArray(), false);
580580

581581
if (_matchesCount === 0) {
582582
return undefined;

src/vs/base/test/common/filters.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,11 @@ suite('Filters', () => {
393393

394394
// issue #17836
395395
// assertTopScore(fuzzyScore, 'TEdit', 1, 'TextEditorDecorationType', 'TextEdit', 'TextEditor');
396-
assertTopScore(fuzzyScore, 'p', 0, 'parse', 'posix', 'pafdsa', 'path', 'p');
396+
assertTopScore(fuzzyScore, 'p', 4, 'parse', 'posix', 'pafdsa', 'path', 'p');
397397
assertTopScore(fuzzyScore, 'pa', 0, 'parse', 'pafdsa', 'path');
398398

399399
// issue #14583
400-
assertTopScore(fuzzyScore, 'log', 3, 'HTMLOptGroupElement', 'ScrollLogicalPosition', 'SVGFEMorphologyElement', 'log');
400+
assertTopScore(fuzzyScore, 'log', 3, 'HTMLOptGroupElement', 'ScrollLogicalPosition', 'SVGFEMorphologyElement', 'log', 'logger');
401401
assertTopScore(fuzzyScore, 'e', 2, 'AbstractWorker', 'ActiveXObject', 'else');
402402

403403
// issue #14446
@@ -415,6 +415,8 @@ suite('Filters', () => {
415415
assertTopScore(fuzzyScore, 'is', 0, 'isValidViewletId', 'import statement');
416416

417417
assertTopScore(fuzzyScore, 'title', 1, 'files.trimTrailingWhitespace', 'window.title');
418+
419+
assertTopScore(fuzzyScore, 'const', 1, 'constructor', 'const', 'cuOnstrul');
418420
});
419421

420422
test('Unexpected suggestion scoring, #28791', function () {

0 commit comments

Comments
 (0)