提交 030f2c5e 编写于 作者: J Johannes Rieken

fuzzyMatch - dot is a separator char

上级 ca84943b
......@@ -440,6 +440,13 @@ export function _matchRecursive(
return (pattern[patternPos] === word[wordPos] ? 17 : 11) + value;
}
if ((idx = word.indexOf(upPattern[patternPos], wordPos)) >= 0
&& ((value = _matchRecursive(pattern, lowPattern, upPattern, patternPos + 1, word, lowWord, idx + 1, matches)) >= 0)
) {
matches.unshift(idx);
return (pattern[patternPos] === word[idx] ? 17 : 11) + value;
}
if ((idx = lowWord.indexOf(`_${lowPatternChar}`, wordPos)) >= 0
&& ((value = _matchRecursive(pattern, lowPattern, upPattern, patternPos + 1, word, lowWord, idx + 2, matches)) >= 0)
) {
......@@ -447,11 +454,11 @@ export function _matchRecursive(
return (pattern[patternPos] === word[idx + 1] ? 17 : 11) + value;
}
if ((idx = word.indexOf(upPattern[patternPos], wordPos)) >= 0
&& ((value = _matchRecursive(pattern, lowPattern, upPattern, patternPos + 1, word, lowWord, idx + 1, matches)) >= 0)
if ((idx = lowWord.indexOf(`.${lowPatternChar}`, wordPos)) >= 0
&& ((value = _matchRecursive(pattern, lowPattern, upPattern, patternPos + 1, word, lowWord, idx + 2, matches)) >= 0)
) {
matches.unshift(idx);
return (pattern[patternPos] === word[idx] ? 17 : 11) + value;
matches.unshift(idx + 1);
return 11 + value;
}
if (patternPos > 0
......
......@@ -235,6 +235,7 @@ suite('Filters', () => {
assertMatches('ccm', 'camelCasecm', '^camel^Casec^m', fuzzyMatchAndScore);
assertMatches('myvable', 'myvariable', '^m^y^v^aria^b^l^e', fuzzyMatchAndScore);
assertMatches('fdm', 'findModel', '^fin^d^Model', fuzzyMatchAndScore);
assertMatches('form', 'editor.formatOnSave', 'editor.^f^o^r^matOnSave', fuzzyMatchAndScore);
});
test('topScore', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册