提交 ea043647 编写于 作者: J Johannes Rieken

recurse with gap-penalty, fixes #23458

上级 d1dba0cc
......@@ -557,7 +557,7 @@ export function fuzzyScore(pattern: string, word: string): [number, number[]] {
}
let bucket: [number, number[]][] = [];
findAllMatches(patternLen, patternLen, wordLen, 0, [], bucket);
findAllMatches(patternLen, patternLen, wordLen, 0, [], bucket, false);
if (bucket.length === 0) {
return undefined;
......@@ -575,9 +575,7 @@ export function fuzzyScore(pattern: string, word: string): [number, number[]] {
return topMatch;
}
function findAllMatches(patternLen: number, patternPos: number, wordPos: number, total: number, matches: number[], bucket: [number, number[]][]): void {
let lastMatched = false;
function findAllMatches(patternLen: number, patternPos: number, wordPos: number, total: number, matches: number[], bucket: [number, number[]][], lastMatched: boolean): void {
while (patternPos > 0 && wordPos > 0) {
......@@ -596,7 +594,7 @@ function findAllMatches(patternLen: number, patternPos: number, wordPos: number,
if (arrow & Arrow.Left) {
// left
findAllMatches(patternLen, patternPos, wordPos - 1, total, matches.slice(0), bucket);
findAllMatches(patternLen, patternPos, wordPos - 1, total, matches.slice(0), bucket, lastMatched);
}
// diag
......
......@@ -231,6 +231,12 @@ suite('Filters', () => {
assertTopScore(fuzzyScore, 'close', 2, 'css.lint.importStatement', 'css.colorDecorators.enable', 'workbench.quickOpen.closeOnFocusOut');
});
test('fuzzyScore, #23458', function () {
assertMatches('highlight', 'editorHoverHighlight', 'editorHover^H^i^g^h^l^i^g^h^t', fuzzyScore);
assertMatches('hhighlight', 'editorHoverHighlight', 'editor^Hover^H^i^g^h^l^i^g^h^t', fuzzyScore);
assertMatches('dhhighlight', 'editorHoverHighlight', undefined, fuzzyScore);
});
test('fuzzyScore', function () {
assertMatches('ab', 'abA', '^a^bA', fuzzyScore);
assertMatches('ccm', 'cacmelCase', '^ca^c^melCase', fuzzyScore);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册