Fix missing global flag in sanitizeId regex#303603
Merged
rzhao271 merged 2 commits intomicrosoft:mainfrom Mar 20, 2026
Merged
Conversation
The regex in sanitizeId was missing the 'g' flag, so only the first occurrence of '.' or '/' was replaced with '_'. Since settings IDs contain multiple dots (e.g. 'editor.font.size'), this meant subsequent dots were left in the sanitized ID.
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @rzhao271Matched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a sanitization bug in the Settings UI tree model where generated element IDs were only partially sanitized, causing IDs derived from setting keys with multiple separators (e.g. editor.font.size) to retain dots/slashes after the first replacement.
Changes:
- Update
sanitizeIdto use a global regex so all.and/characters are replaced with_during ID generation.
src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts
Outdated
Show resolved
Hide resolved
Export sanitizeId and add a test verifying that all occurrences of '.' and '/' are replaced in generated tree element IDs, not just the first.
rzhao271
approved these changes
Mar 20, 2026
mjbvz
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #303601
The
sanitizeIdregex was missing theg(global) flag, soString.prototype.replaceonly replaced the first occurrence of.or/. Since settings IDs contain multiple dots (e.g.,editor.font.size), only the first one was being sanitized to_.Before:
"root.editor.font.size"->"root_editor.font.size"After:
"root.editor.font.size"->"root_editor_font_size"