diff --git a/src/vs/base/common/fuzzyScorer.ts b/src/vs/base/common/fuzzyScorer.ts index f01f75b13a022..f6ec001820a40 100644 --- a/src/vs/base/common/fuzzyScorer.ts +++ b/src/vs/base/common/fuzzyScorer.ts @@ -208,8 +208,11 @@ function computeCharScore(queryCharAtIndex: string, queryLowerCharAtIndex: strin // } } - // Inside word upper case bonus (camel case) - else if (isUpper(target.charCodeAt(targetIndex))) { + // Inside word upper case bonus (camel case). We only give this bonus if we're not in a contiguous sequence. + // For example: + // NPE => NullPointerException = boost + // HTTP => HTTP = not boost + else if (isUpper(target.charCodeAt(targetIndex)) && matchesSequenceLength === 0) { score += 2; // if (DEBUG) { diff --git a/src/vs/base/test/common/fuzzyScorer.test.ts b/src/vs/base/test/common/fuzzyScorer.test.ts index 59966767cb579..4982bfb8b83af 100644 --- a/src/vs/base/test/common/fuzzyScorer.test.ts +++ b/src/vs/base/test/common/fuzzyScorer.test.ts @@ -403,6 +403,13 @@ suite('Fuzzy Scorer', () => { } }); + test('scoreItem - ensure upper case bonus only applies on non-consecutive matches (bug #134723)', function () { + const resourceWithUpper = URI.file('ASDFasdfasdf'); + const resourceAllLower = URI.file('asdfasdfasdf'); + + assert.ok(scoreItem(resourceAllLower, 'asdf', true, ResourceAccessor).score > scoreItem(resourceWithUpper, 'asdf', true, ResourceAccessor).score); + }); + test('compareItemsByScore - identity', function () { const resourceA = URI.file('/some/path/fileA.txt'); const resourceB = URI.file('/some/path/other/fileB.txt');