提交 8e9151a4 编写于 作者: J Johannes Rieken

ensure fuzzy score limit is what it is, #66923

上级 b3e5d256
......@@ -378,16 +378,13 @@ export function createMatches(score: undefined | FuzzyScore): IMatch[] {
return [];
}
const [, matches, wordStart] = score;
const matches = score[1].toString(2);
const wordStart = score[2];
const res: IMatch[] = [];
for (let pos = wordStart; pos < _masks.length; pos++) {
const mask = _masks[pos];
if (mask > matches) {
break;
} else if (matches & mask) {
for (let pos = wordStart; pos < _maxLen; pos++) {
if (matches[matches.length - (pos + 1)] === '1') {
const last = res[res.length - 1];
if (last && last.end === pos) {
last.end = pos + 1;
} else {
......@@ -400,14 +397,6 @@ export function createMatches(score: undefined | FuzzyScore): IMatch[] {
const _maxLen = 53;
const _masks = (function () {
const result: number[] = [];
for (let pos = 0; pos < _maxLen; pos++) {
result.push(2 ** pos);
}
return result;
}());
function initTable() {
const table: number[][] = [];
const row: number[] = [0];
......
......@@ -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 } from 'vs/base/common/filters';
import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords, fuzzyScore, IMatch, fuzzyScoreGraceful, fuzzyScoreGracefulAggressive, FuzzyScorer, createMatches } from 'vs/base/common/filters';
function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, highlights?: { start: number; end: number; }[]) {
let r = filter(word, wordToMatchAgainst);
......@@ -208,14 +208,15 @@ suite('Filters', () => {
let r = filter(pattern, pattern.toLowerCase(), opts.patternPos || 0, word, word.toLowerCase(), opts.wordPos || 0, opts.firstMatchCanBeWeak || false);
assert.ok(!decoratedWord === !r);
if (r) {
let [, matches] = r;
let matches = createMatches(r);
let actualWord = '';
for (let pos = 0; pos < word.length; pos++) {
if (2 ** pos & matches) {
actualWord += '^';
}
actualWord += word[pos];
let pos = 0;
for (const match of matches) {
actualWord += word.substring(pos, match.start);
actualWord += '^' + word.substring(match.start, match.end).split('').join('^');
pos = match.end;
}
actualWord += word.substring(pos);
assert.equal(actualWord, decoratedWord);
}
}
......@@ -450,7 +451,7 @@ suite('Filters', () => {
assertMatches('cno', 'co_new', '^c^o_^new', fuzzyScoreGracefulAggressive);
});
// test('List highlight filter: Not all characters from match are highlighterd #66923', () => {
// assertMatches('foo', 'barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_foo', 'barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_^f^o^o', fuzzyScore);
// });
test('List highlight filter: Not all characters from match are highlighterd #66923', () => {
assertMatches('foo', 'barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_foo', 'barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar_^f^o^o', fuzzyScore);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册