Repository: microsoft/vscode (TypeScript) — Bug Fix

Issue:
'search files' popup should favor case-sensitive matches
Issue Type: <b>Bug</b>

I have two files in my project in different locations. `HTTPClient.cpp` and `HttpClient.cpp`.

The 'search in files' popup always shows `HTTPClient` first, event when searching for the latter:

![image](https://user-images.githubusercontent.com/1088194/136674158-8ab523c2-8b77-45b3-9145-806c56be88c6.png)

please include case-sensitivity in the sort function for this.

VS Code version: Code 1.60.2 (7f6ab5485bbc008386c4386d08766667e155244e, 2021-09-22T12:00:31.514Z)
OS version: Windows_NT x64 10.0.19043
Restricted Mode: No
Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2
Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2
Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2
Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2904)|
|GPU Status|2d_canvas: enabled<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>oop_rasterization: enabled<br>opengl: enabled_on<br>rasterization: enabled<br>skia_renderer: enabled_on<br>video_decode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|47.66GB (14.45GB free)|
|Process Argv|--crash-reporter-id 70645636-42ae-4864-b371-1810b42a2956|
|Screen Reader|no|
|VM|0%|

|Item|Value|
|---|---|
|Remote|WSL: CentOS7|
|OS|Linux x64 5.10.16.3-microsoft-standard-WSL2|
|CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2904)|
|Memory (System)|37.35GB (11.26GB free)|
|VM|0%|

|Item|Value|
|---|---|
|Remote|WSL: CentOS7|
|OS|Linux x64 5.10.16.3-microsoft-standard-WSL2|
|CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2904)|
|Memory (System)|37.35GB (11.26GB free)|
|VM|0%|

|Item|Value|
|---|---|
|Remote|WSL: CentOS7|
|OS|Linux x64 5.10.16.3-microsoft-standard-WSL2|
|CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2904)|
|Memory (System)|37.35GB (11.26GB free)|
|VM|0%|

|Item|Value|
|---|---|
|Remote|WSL: CentOS7|
|OS|Linux x64 5.10.16.3-microsoft-standard-WSL2|
|CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2904)|
|Memory (System)|37.35GB (11.26GB free)|
|VM|0%|
</details><details><summary>Extensions (5)</summary>

Extension|Author (truncated)|Version
---|---|---
jupyter-keymap|ms-|1.0.0
remote-ssh|ms-|0.65.8
remote-ssh-edit|ms-|0.65.8
remote-wsl|ms-|0.58.2
hexeditor|ms-|1.8.2


</details><details>
<summary>A/B Experiments</summary>

```
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
pythonvspyt639:30300192
pythontb:30283811
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
vscorecescf:30358481
pythondataviewer:30285071
pythonvsuse255:30340121
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
vsccppwtct:30378365
pythonvssor306:30344512
bridge0708:30335490
pygetstartedt2:30371810
dockerwalkthru:30377721
bridge0723:30353136
pythonrunftest32:30373476
pythonf5test824:30373475
javagetstartedc:30364665
pythonvspyt187:30373474
pydsgst2:30361792
vsqsis200:30374795
vsaa593cf:30376535

```

</details>

<!-- generated by issue reporter -->


Discussion:

Resolving patch:
diff --git a/src/vs/base/common/fuzzyScorer.ts b/src/vs/base/common/fuzzyScorer.ts
--- 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) {


Test patch:
diff --git a/src/vs/base/test/common/fuzzyScorer.test.ts b/src/vs/base/test/common/fuzzyScorer.test.ts
--- 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');