Skip to content

sanitizeId regex missing global flag - only first dot/slash is replaced in settings tree IDs #303601

@ShehabSherif0

Description

@ShehabSherif0

Bug

The sanitizeId function in settingsTreeModels.ts uses a regex without the g (global) flag:

function sanitizeId(id: string): string {
    return id.replace(/[\.\/]/, '_');
}

Without the g flag, String.prototype.replace only replaces the first match. Since settings IDs contain multiple dots (e.g., root.editor.font.size), only the first dot gets replaced:

Input:  "root.editor.font.size"
Actual: "root_editor.font.size"   // only first dot replaced
Expected: "root_editor_font_size" // all dots replaced

Fix

Add the g flag to the regex: /[\.\/]/g

Location

  • File: src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts, line 755

Metadata

Metadata

Assignees

Labels

debtCode quality issuesinsiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions