diff --git a/src/vs/base/common/filters.ts b/src/vs/base/common/filters.ts index 5e16f0462dca5ccc7c785088bf25913200b18f05..d0ba021e86736250b6d52de57a445907a53daaa6 100644 --- a/src/vs/base/common/filters.ts +++ b/src/vs/base/common/filters.ts @@ -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 diff --git a/src/vs/base/test/common/filters.test.ts b/src/vs/base/test/common/filters.test.ts index a9f118e80d242972648ea787aca79a391f0e8e17..72c6fa4b32109a43d001c000a76b7ede92a36ea0 100644 --- a/src/vs/base/test/common/filters.test.ts +++ b/src/vs/base/test/common/filters.test.ts @@ -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 () {