microsoft / microsoft/vscode

Diff View menu shows wrong selected layout with workspace-folder-specific `diffEditor.renderSideBySide`

Open
#336,886 1 comment 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

new release
Dominant language
TypeScript
Stars
193k
Forks
42.7k
PR merge metrics
PR metrics pending

Description

mmexport1789834458598.jpg

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.138.0
  • OS Version: Windows 11

Steps to Reproduce:

  1. Create two folders, a and b, and add both to the same multi-root workspace.

  2. Create a/test.txt and b/test.txt with different contents.

  3. Set the User setting:

   "diffEditor.renderSideBySide": true
  1. Create a/.vscode/settings.json containing:
   {
     "diffEditor.renderSideBySide": false
   }

Do not set diffEditor.renderSideBySide in folder b.

  1. Open b/test.txt.

  2. Run Compare Active File With... and select a/test.txt.

    The diff now has:

   original = b/test.txt
   modified = a/test.txt
  1. 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:

  • TextDiffEditor uses the modified editor as its main control.
  • AbstractTextEditor resolves 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 writes diffEditor.renderSideBySide through ITextResourceConfigurationService for 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.