Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't count upper case bonus if the letters are consecutive #135930

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/vs/base/common/fuzzyScorer.ts
Expand Up @@ -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) {
TylerLeonhardt marked this conversation as resolved.
Show resolved Hide resolved
score += 2;

// if (DEBUG) {
Expand Down
7 changes: 7 additions & 0 deletions src/vs/base/test/common/fuzzyScorer.test.ts
Expand Up @@ -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');
Expand Down