提交 096b8fc2 编写于 作者: J Johannes Rieken

more separator character that boost a match, #22153

上级 5c08b6e6
......@@ -433,6 +433,13 @@ function printTable(table: number[][], pattern: string, patternLen: number, word
return ret;
}
const _seps: { [ch: string]: boolean } = Object.create(null);
_seps['_'] = true;
_seps['.'] = true;
_seps[' '] = true;
_seps['/'] = true;
_seps['\\'] = true;
export function fuzzyScore(pattern: string, word: string): [number, number[]] {
const patternLen = pattern.length > 25 ? 25 : pattern.length;
......@@ -484,7 +491,7 @@ export function fuzzyScore(pattern: string, word: string): [number, number[]] {
} else {
score = 5;
}
} else if (lastLowWordChar === '_' || lastLowWordChar === '.') {
} else if (_seps[lastLowWordChar]) {
score = 5;
} else if (j === i) {
......
......@@ -251,6 +251,13 @@ suite('Filters', () => {
assertMatches('sllll', 'SVisualLoggerLogsList', '^SVisua^l^Logger^Logs^List', fuzzyScore);
assertMatches('Three', 'HTMLHRElement', 'H^TML^H^R^El^ement', fuzzyScore);
assertMatches('Three', 'Three', '^T^h^r^e^e', fuzzyScore);
assertMatches('fo', 'barfoo', undefined, fuzzyScore);
assertMatches('fo', 'bar_foo', 'bar_^f^oo', fuzzyScore);
assertMatches('fo', 'bar_Foo', 'bar_^F^oo', fuzzyScore);
assertMatches('fo', 'bar foo', 'bar ^f^oo', fuzzyScore);
assertMatches('fo', 'bar.foo', 'bar.^f^oo', fuzzyScore);
assertMatches('fo', 'bar/foo', 'bar/^f^oo', fuzzyScore);
assertMatches('fo', 'bar\\foo', 'bar\\^f^oo', fuzzyScore);
});
function assertTopScore(filter: typeof fuzzyScore, pattern: string, expected: number, ...words: string[]) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册