fix: multi-language workspace setting should override single-language user setting #285034
+41
−0
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.
Closes #168411.
Here's the summary from Claude:
Fix for Bug #168411: Multi-language workspace setting should override single-language user setting
Problem Description
When a user has a single-language override in their user settings (e.g.,
[javascript]) and a multi-language override in their workspace settings (e.g.,[javascript][typescript]), the single-language user setting was incorrectly taking precedence over the multi-language workspace setting.Expected Behavior
Workspace settings should always override user settings, regardless of whether they are single-language or multi-language overrides.
Actual Behavior (Before Fix)
Single-language overrides were always given priority over multi-language overrides, even when the multi-language override came from a higher-priority configuration source (workspace).
Root Cause
The issue was in the configuration merging logic. When merging user and workspace configurations:
[javascript]override from user settings and the multi-language[javascript][typescript]override from workspace settings were kept in the merged resultgetContentsForOverrideIdentifermethod had logic that always gave single-language overrides precedence over multi-language onesAfter merging, there was no way to distinguish which override came from which source, so the single-language override always won.
Solution
The fix modifies the
mergefunction inConfigurationModelto remove single-language overrides from earlier configuration sources when a multi-language override is added from a later source.Changes Made
1. Modified
ConfigurationModel.merge()(configurationModels.ts)When merging configurations, if a multi-language override is being added and it doesn't match any existing override by identifier array, the merge function now:
2. Added a test (configurationModels.test.ts)
n/a
Behavior Analysis
Scenario 1: User single-language + Workspace multi-language (Bug #168411)
Scenario 2: Single config with both override types (Existing test)
Why This Works
Testing
The fix includes a test case that verifies:
[javascript]override settingeditor.tabSize: 2[javascript][typescript]override settingeditor.tabSize: 4javascriptreturns4(workspace value)Test Output
Files Changed
src/vs/platform/configuration/common/configurationModels.ts- Modifiedmerge()functionsrc/vs/platform/configuration/test/common/configurationModels.test.ts- Fixed test case structure