Skip to content

Commit 1126817

Browse files
committed
simple change for microsoft#79815
1 parent 2e26a4f commit 1126817

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/vs/base/common/filters.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,12 @@ export interface FuzzyScorer {
532532

533533
export function fuzzyScore(pattern: string, patternLow: string, patternPos: number, word: string, wordLow: string, wordPos: number, firstMatchCanBeWeak: boolean): FuzzyScore | undefined {
534534

535+
if (patternPos > 0) {
536+
pattern = pattern.substr(patternPos);
537+
patternLow = patternLow.substr(patternPos);
538+
patternPos = 0;
539+
}
540+
535541
const patternLen = pattern.length > _maxLen ? _maxLen : pattern.length;
536542
const wordLen = word.length > _maxLen ? _maxLen : word.length;
537543

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ suite('Filters', () => {
389389
assertMatches('g', 'zzGroup', 'zz^Group', fuzzyScore);
390390
});
391391

392+
test('patternPos isn\'t working correctly #79815', function () {
393+
assertMatches(':p'.substr(1), 'prop', '^prop', fuzzyScore, { patternPos: 0 });
394+
assertMatches(':p', 'prop', '^prop', fuzzyScore, { patternPos: 1 });
395+
});
396+
392397
function assertTopScore(filter: typeof fuzzyScore, pattern: string, expected: number, ...words: string[]) {
393398
let topScore = -(100 * 10);
394399
let topIdx = 0;

src/vs/workbench/contrib/quickopen/browser/gotoSymbolHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class OutlineModel extends QuickOpenModel {
8888
// Filter by search
8989
if (searchValue.length > searchValuePos) {
9090
const score = filters.fuzzyScore(
91-
searchValue.substr(searchValuePos), searchValueLow.substr(searchValuePos), 0,
91+
searchValue, searchValueLow, searchValuePos,
9292
entry.getLabel(), entry.getLabel().toLowerCase(), 0,
9393
true
9494
);

0 commit comments

Comments
 (0)