Repository navigation
fix: match uppercase query characters in fuzzyContains - #324047
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes fuzzyContains in vs/base/common/strings so uppercase (and mixed-case) query characters can match by making the comparison case-insensitive on both the target and query. This addresses a real user-facing regression in the Views Quick Access picker where uppercase input could not match container labels.
Changes:
- Lowercase the
queryinfuzzyContainsbefore performingindexOfcomparisons. - Extend the
fuzzyContainsunit tests with uppercase and mixed-case query assertions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/base/common/strings.ts | Makes fuzzyContains compare against a lowercased query to enable case-insensitive fuzzy matching. |
| src/vs/base/test/common/strings.test.ts | Adds coverage for uppercase and mixed-case queries to prevent regressions. |
Dirk Bäumer (dbaeumer)
left a comment
There was a problem hiding this comment.
See Copilot review
toLowerCase() can change a string's length (e.g. the query 'İ' lowercases to 'i̇', two code units), so bounding the loop by the original query.length skipped trailing lowered code units. Iterate over queryLower.length instead and cover the case with a regression test.
|
Good catch, thanks. The loop now iterates over |
|
@microsoft-github-policy-service agree |
|
roblourens used from search. |
|
Please open an issue and give a clear description of the actual problem you're solving. I can't repro an issue in the view quick access |
|
The core problem is that Separately, lowercasing can change the query's length: This is at the |
|
I understand the change to the function, but I'm trying to understand the user-visible bug in the product that is being fixed |
|
It does surface in one place: the "Open View" quick access ( An entry there matches if either its view label fuzzy-matches (case-insensitive Repro:
So typing a container name exactly as shown (capitalized) returns fewer results than the lowercase form. The other two callers don't surface it because they pre-lowercase the query first: the Test Explorer filter ( |
|
Thanks, I see that now. Please open an issue for this- that's how we track work in this repo. |
|
Opened #325664 with the repro and root cause. |
TylerLeonhardt
left a comment
There was a problem hiding this comment.
LGTM thanks for contributing!
Pull request was converted to draft
(Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| const queryLen = query.length; | ||
| const targetLower = target.toLowerCase(); | ||
| const queryLower = query.toLowerCase(); | ||
| // toLowerCase() can change a string's length (e.g. \u0130 -> i\u0307), so iterate over the lowered query. |
fuzzyContainslowercases the target but compares it against the original-casequery characters, so any uppercase character in the query can never match.
The
viewQuickAccesspicker passes the raw user filter intofuzzyContains(entry.containerLabel, filter)after only trimming it, so typingan uppercase letter fails to fuzzy-match views by container label. Other callers
happened to work only because they lowercase both sides before calling, which
hid the defect at the utility level.
The fix lowercases the query as well, so the comparison is case-insensitive on
both sides. Added assertions for uppercase and mixed-case queries.