d'oh, forgot to adjust anyScore to new data format of FuzzyScore, fixes https://github.com/microsoft/vscode/issues/115250

This commit is contained in:
Johannes Rieken
2021-01-28 09:13:33 +01:00
parent 7a9e56510d
commit 70de88696c
2 changed files with 14 additions and 9 deletions
+7 -8
View File
@@ -370,24 +370,23 @@ export function anyScore(pattern: string, lowPattern: string, _patternPos: numbe
if (result) {
return result;
}
let matches = 0;
let matches: number[] = [];
let score = 0;
let idx = _wordPos;
for (let patternPos = 0; patternPos < lowPattern.length && patternPos < _maxLen; ++patternPos) {
const wordPos = lowWord.indexOf(lowPattern.charAt(patternPos), idx);
if (wordPos >= 0) {
score += 1;
matches += 2 ** wordPos;
matches.unshift(wordPos);
idx = wordPos + 1;
} else if (matches !== 0) {
} else if (matches.length > 0) {
// once we have started matching things
// we need to match the remaining pattern
// characters
break;
}
}
return [score, _wordPos, matches];
return [score, _wordPos, ...matches];
}
//#region --- fuzzyScore ---
@@ -536,9 +535,9 @@ const enum Arrow { Diag = 1, Left = 2, LeftLeft = 3 }
*
* 0. the score
* 1. the offset at which matching started
* 2. `<match_pos_1>`
* 3. `<match_pos_2>`
* 4. `<match_pos_3>` etc
* 2. `<match_pos_N>`
* 3. `<match_pos_1>`
* 4. `<match_pos_0>` etc
*/
export type FuzzyScore = [score: number, wordStart: number, ...matches: number[]];// [number, number, number];
+7 -1
View File
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords, fuzzyScore, IMatch, fuzzyScoreGraceful, fuzzyScoreGracefulAggressive, FuzzyScorer, createMatches } from 'vs/base/common/filters';
import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords, fuzzyScore, IMatch, fuzzyScoreGraceful, fuzzyScoreGracefulAggressive, FuzzyScorer, createMatches, anyScore } from 'vs/base/common/filters';
function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, highlights?: { start: number; end: number; }[]) {
let r = filter(word, wordToMatchAgainst);
@@ -549,4 +549,10 @@ suite('Filters', () => {
assertMatches('SemanticTokens', 'SemanticTokensEdits', '^S^e^m^a^n^t^i^c^T^o^k^e^n^sEdits', fuzzyScore);
assertMatches('SemanticTokens', 'SemanticTokensEdits', '^S^e^m^a^n^t^i^c^T^o^k^e^n^sEdits', fuzzyScoreGracefulAggressive);
});
test('IntelliSense completion not correctly highlighting text in front of cursor #115250', function () {
assertMatches('lo', 'log', '^l^og', fuzzyScore);
assertMatches('.lo', 'log', '^l^og', anyScore);
assertMatches('.', 'log', 'log', anyScore);
});
});