Skip to content

fix: match uppercase query characters in fuzzyContains - #324047

Merged
roblourens merged 3 commits into
microsoft:mainfrom
spokodev:w33/vscode-fuzzycontains-uppercase
Jul 14, 2026
Merged

roblourens merged 3 commits into
microsoft:mainfrom
spokodev:w33/vscode-fuzzycontains-uppercase

Conversation

@spokodev

Copy link
Copy Markdown
Contributor

fuzzyContains lowercases the target but compares it against the original-case
query characters, so any uppercase character in the query can never match.

fuzzyContains('hello world', 'H')  // false, should be true
fuzzyContains('Explorer', 'E')     // false, should be true

The viewQuickAccess picker passes the raw user filter into
fuzzyContains(entry.containerLabel, filter) after only trimming it, so typing
an 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.

Copilot AI review requested due to automatic review settings July 2, 2026 12:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 query in fuzzyContains before performing indexOf comparisons.
  • Extend the fuzzyContains unit 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.
Comment thread src/vs/base/common/strings.ts Resolved

@dbaeumer Dirk Bäumer (dbaeumer) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@spokodev

Copy link
Copy Markdown
Contributor Author

Good catch, thanks. The loop now iterates over queryLower.length instead of the original query.length, so a query whose lowercase form changes length (İ lowercases to i̇) no longer skips its trailing code units. Added a regression test for that case.

@spokodev

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@dbaeumer

Copy link
Copy Markdown
Member

roblourens used from search.

@roblourens

Copy link
Copy Markdown
Member

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

@spokodev

Copy link
Copy Markdown
Contributor Author

The core problem is that fuzzyContains lowercases only the target, not the query, so any uppercase character in the query fails to match:

strings.fuzzyContains('hello world', 'H') // false, expected true

Separately, lowercasing can change the query's length: İ (U+0130) lowercases to two code units (i + combining dot U+0307), so bounding the loop by the original query.length skips a code unit. The fix lowercases the query and iterates over queryLower.length.

This is at the fuzzyContains level rather than the view quick access specifically, which is likely why it didn't repro there. Happy to open a tracking issue if you'd prefer that.

@roblourens

Copy link
Copy Markdown
Member

I understand the change to the function, but I'm trying to understand the user-visible bug in the product that is being fixed

@spokodev

Copy link
Copy Markdown
Contributor Author

It does surface in one place: the "Open View" quick access (View: Open View, or the view prefix in Quick Open). The PR body has the right framing; my earlier follow-up muddied it.

An entry there matches if either its view label fuzzy-matches (case-insensitive matchesFuzzy) or its container label matches via fuzzyContains(entry.containerLabel, filter). That container path is the only case-sensitive one, so filtering by container name works only in lowercase.

Repro:

  1. Run "View: Open View".
  2. Type explorer. Views grouped under the Explorer container (e.g. Outline, Timeline) appear, matched by their container label.
  3. Type Explorer (capital E, as the UI displays it). Those entries drop out, because fuzzyContains lowercases the target ("explorer") but tests it against the raw query character E.

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 (testExplorerFilterState lowercases each glob term) and file search (normalizedFilePatternLowercase / prepareQuery().normalizedLowercase). So the user-visible blast radius is just Open View.

@roblourens

Copy link
Copy Markdown
Member

Thanks, I see that now. Please open an issue for this- that's how we track work in this repo.

@spokodev

Copy link
Copy Markdown
Contributor Author

Opened #325664 with the repro and root cause.

TylerLeonhardt
TylerLeonhardt previously approved these changes Jul 13, 2026

@TylerLeonhardt TylerLeonhardt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for contributing!

@TylerLeonhardt
TylerLeonhardt enabled auto-merge (squash) July 13, 2026 21:46
roblourens
roblourens previously approved these changes Jul 14, 2026
@roblourens
roblourens marked this pull request as draft July 14, 2026 17:59
auto-merge was automatically disabled July 14, 2026 17:59

Pull request was converted to draft

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens
roblourens dismissed stale reviews from TylerLeonhardt and themself via 939e110 July 14, 2026 18:09
@roblourens
roblourens marked this pull request as ready for review July 14, 2026 18:21
@roblourens
roblourens enabled auto-merge (squash) July 14, 2026 18:21
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love Turkish

@roblourens
roblourens merged commit 5a1699c into microsoft:main Jul 14, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.130.0 milestone Jul 14, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

6 participants