Diff View menu shows wrong selected layout with workspace-folder-specific `diffEditor.renderSideBySide`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.7k
- PR merge metrics
- PR metrics pending
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.138.0
- OS Version: Windows 11
Steps to Reproduce:
-
Create two folders,
aandb, and add both to the same multi-root workspace. -
Create
a/test.txtandb/test.txtwith different contents. -
Set the User setting:
"diffEditor.renderSideBySide": true
- Create
a/.vscode/settings.jsoncontaining:
{
"diffEditor.renderSideBySide": false
}
Do not set diffEditor.renderSideBySide in folder b.
-
Open
b/test.txt. -
Run Compare Active File With... and select
a/test.txt.The diff now has:
original = b/test.txt
modified = a/test.txt
- Open More Actions → Diff View.
Actual Behavior
The diff editor is rendered Inline, which matches the effective configuration for the modified resource (a/test.txt):
"diffEditor.renderSideBySide": false
However, Diff View has Side by Side checked.
After swapping the diff sides so that:
original = a/test.txt
modified = b/test.txt
the editor renders Side by Side, and the menu also shows Side by Side.
Expected Behavior
The checked item in Diff View should reflect the effective diff view configuration used by the current diff editor.
In the first comparison above, Inline should be checked.
Additional Observations
Only diffEditor.renderSideBySide is required to reproduce the issue.
Changing the Diff View mode while a/test.txt is the modified resource updates a/.vscode/settings.json.
Changing it while b/test.txt is the modified resource, where no workspace-folder override exists, updates the User setting instead.
This makes the two diff orientations capable of using different effective layouts.
Investigation
The actual diff editor configuration is resource-aware:
TextDiffEditoruses the modified editor as its main control.AbstractTextEditorresolves editor configuration using the active resource, which for a text diff is the modified model URI.DiffEditorCommandsService.setViewMode()also resolves the modified model URI and writesdiffEditor.renderSideBySidethroughITextResourceConfigurationServicefor that resource.
The checked state of the Diff View submenu is determined differently.
In src/vs/workbench/browser/parts/editor/editor.contribution.ts, the menu uses config.diffEditor.renderSideBySide in its toggled expressions.
config.* context values are resolved by ConfigAwareContextValuesContainer in src/vs/platform/contextkey/browser/contextKeyService.ts through:
this._configurationService.getValue(configKey)
without a resource override.
As a result, the editor and its commands can use the modified resource's workspace-folder-specific effective value while the menu's checked state is evaluated from a configuration value resolved without that resource context.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/vs/workbench/browser/parts/editor/editor.contribution.ts, where the Diff View menu's toggled expressions use config.diffEditor.renderSideBySide. Then inspect ConfigAwareContextValuesContainer in src/vs/platform/contextkey/browser/contextKeyService.ts and compare its configuration lookup with the modified resource used by TextDiffEditor and DiffEditorCommandsService. Reproduce the multi-root comparison and verify that the checked menu item matches the effective layout for the modified resource.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100