Skip to content

Conversation

@dmitrivMS
Copy link
Contributor

@dmitrivMS dmitrivMS commented Nov 11, 2025

Fixes #270711

Added new tryNormalizeToBase method to normalization.ts which will perform NFD+accent removal+lower casing and cache the result.

Removed removeAccents since it was not used after this change and it is not safe to use (does not preserve the indices).

Moved accent-insensitive logic to filters.txt by using the new tryNormalizeToBase method.

Replaced filters that match on natural language and used matchesPrefix or matchesContiguousSubString with a single call to matchesBaseContiguousSubString filter which will do both. This does change the order of preferences (contiguous substring will now take precedence other words), but it will make one less filtering call per item.

Updated unit-tests.

Note: The intent of getAlternateCodes is similar to what tryNormalizeToBase is doing, but at the same time building tables for all Unicode accents and combined characters into our code seems impractical, so keep those two separate, although normalization will occur before Korean replacement, so the two will work together in matchesWords case.

Copilot AI review requested due to automatic review settings November 11, 2025 20:17
@dmitrivMS dmitrivMS added the debt Code quality issues label Nov 11, 2025
@dmitrivMS dmitrivMS enabled auto-merge (squash) November 11, 2025 20:17
@dmitrivMS dmitrivMS self-assigned this Nov 11, 2025
@vs-code-engineering
Copy link

vs-code-engineering bot commented Nov 11, 2025

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@rzhao271

Matched files:

  • src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts

Copilot finished reviewing on behalf of dmitrivMS November 11, 2025 20:18
@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 11, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR moves accent-insensitive filtering logic from various files into a centralized tryNormalizeToBase method in normalization.ts. The new method performs NFD normalization, accent removal, and lower casing with caching support, while ensuring string length preservation to maintain index consistency.

  • Adds new tryNormalizeToBase method that combines NFD normalization, accent removal, and lower casing with LRU caching
  • Introduces matchesBaseContiguousSubString filter that uses the new normalization
  • Removes the removeAccents function and custom normalization logic from commandsQuickAccess.ts

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/base/common/normalization.ts Removes removeAccents, adds tryNormalizeToBase with caching and length-preserving logic
src/vs/base/common/filters.ts Adds matchesBaseContiguousSubString filter, updates matchesWords and matchesContiguousSubString to use normalization, fixes typo in comment
src/vs/platform/quickinput/browser/commandsQuickAccess.ts Removes custom normalization logic and unused fields, simplifies filtering to use new matchesBaseContiguousSubString
src/vs/workbench/services/preferences/browser/keybindingsEditorModel.ts Updates wordFilter to use matchesBaseContiguousSubString instead of matchesPrefix and matchesContiguousSubString
src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts Updates to use matchesBaseContiguousSubString for description matching
src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsViewModel.ts Updates wordFilter to use matchesBaseContiguousSubString
src/vs/base/test/common/normalization.test.ts Updates tests from removeAccents to tryNormalizeToBase, adds new test cases for case handling
src/vs/base/test/common/filters.test.ts Adds test coverage for new matchesBaseContiguousSubString filter

Copy link
Contributor

Copilot AI commented Nov 11, 2025

@dmitrivMS I've opened a new pull request, #276800, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Nov 11, 2025

@dmitrivMS I've opened a new pull request, #276801, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

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

Very nice

@dmitrivMS dmitrivMS merged commit bd64c17 into main Nov 11, 2025
28 checks passed
@dmitrivMS dmitrivMS deleted the dev/dmitriv/filtering branch November 11, 2025 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Code quality issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move accent normalization into filters.ts

3 participants