Skip to content

Make structural diffs reusable outside the Source Control view - #350137

Draft
Dirk Bäumer (dbaeumer) wants to merge 1 commit into
mainfrom
dbaeumer/structural-diff-model
Draft

Dirk Bäumer (dbaeumer) wants to merge 1 commit into
mainfrom
dbaeumer/structural-diff-model

Conversation

@dbaeumer

@dbaeumer Dirk Bäumer (dbaeumer) commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Part 2 of 3 stacked PRs that show structural changes in the file list of the multi-file diff editor:

  1. Fix revealing ranges below the first screen in multi-file diffs #350136: revealing ranges below the first screen in multi-file diffs (merged)
  2. Make structural diffs reusable outside the Source Control view #350137: reusable structural diff model, renderer and toggle (this PR)
  3. Show structural changes in the multi-file diff editor's file list #350138: structural changes in the multi-file diff editor's file list

Prepares structural diffs for views other than the Source Control view, which the next PR uses for the file list of the multi-file diff editor. The Source Control view does not change.

Change

  • StructuralDiffModel<T> in scmStructuralDiff.ts loads, caches and refreshes the structural changes of any kind of file. An IStructuralDiffResourceAdapter<T> tells which documents a file compares, how its elements are identified, and which view it belongs to. SCMStructuralDiffModel is the Source Control view's subclass. The scmStructuralDiffRequested telemetry event gains a location property, scm or multiDiffEditor.
  • getSCMStructuralDiffTarget returns where a diff editor shows a structural item. openSCMStructuralDiff uses it, and so will the file list.
  • The state of Show Structural Diff moved from SCMViewPane into ISCMViewService (showStructuralDiff and setShowStructuralDiff), with the same workspace storage key, so that other views can follow it without reading the storage of the Source Control view.
  • The styles of structural rows that do not depend on the Source Control view moved from scm.css into scmStructuralDiff.css, which the renderer imports.

Testing

  • scripts\test.bat --run src/vs/workbench/contrib/scm/test/browser/scmStructuralDiff.test.ts --run src/vs/workbench/contrib/scm/test/browser/scmViewService.test.ts --run src/vs/workbench/contrib/scm/test/common/scmStructuralDiff.test.ts: passed (96 tests), including a new test of the Show Structural Diff state in the service.
  • pnpm run typecheck-client: passed.
  • pnpm run stylelint on the changed CSS files: passed.
  • The pre-commit hygiene check, including oxlint, on the changed files: passed.
  • Component explorer: the screenshots of the structural fixtures in scm/scmStructuralDiff and scm/scmResourceDecorations (dark theme, 9 fixtures) are identical to those of main.

@dbaeumer
Dirk Bäumer (dbaeumer) force-pushed the dbaeumer/structural-diff-model branch 8 times, most recently from 5043686 to 9e3a1e4 Compare November 25, 2026 13:23
Base automatically changed from dbaeumer/multi-diff-reveal-range to main November 25, 2026 14:10
@dbaeumer
Dirk Bäumer (dbaeumer) requested a balanced review from Copilot November 25, 2026 14:28
The model that loads and refreshes the structural changes of files now
works with any kind of file, which an adapter describes, and reports in
telemetry which view requested them. The Source Control view uses it
through a subclass. Finding where a diff editor shows a structural item
moved into a helper that other views can use too.

The state of Show Structural Diff moved from the Source Control view
into the SCM view service, so that other views can follow it, and the
styles of structural rows that do not depend on the Source Control view
moved into a stylesheet that the renderer imports. The Source Control
view does not change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dbaeumer
Dirk Bäumer (dbaeumer) force-pushed the dbaeumer/structural-diff-model branch from 9e3a1e4 to 8a0f771 Compare November 25, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Active findings identify incorrect reveal positioning after wrapped inline deletions and a reveal wait that can remain unresolved and retain removed items when pending diffs are canceled.

No open issues 🎉

What changed in this PR

Prepares structural diffs for reuse outside Source Control, ahead of the multi-file diff editor’s structural file list. The stacked changes also improve range navigation in multi-file diffs.

Changes:

  • Extracts an adapter-based structural diff model, shared renderer styles, and navigation target helper.
  • Moves the workspace visibility toggle into ISCMViewService and adds telemetry location tracking.
  • Improves range revealing for wrapped, deleted, collapsed, and pending diff content, with regression tests.
File Description
src/​vs/​workbench/​contrib/​scm/​test/​common/​scmStructuralDiff.test.ts Updates telemetry expectations with the view location.
src/​vs/​workbench/​contrib/​scm/​test/​browser/​scmViewService.test.ts Tests shared structural diff visibility state.
src/​vs/​workbench/​contrib/​scm/​test/​browser/​scmStructuralDiff.test.ts Tests the service-backed toggle command.
src/​vs/​workbench/​contrib/​scm/​common/​scmStructuralDiff.ts Extracts the generic model, adapter, and navigation helper.
src/​vs/​workbench/​contrib/​scm/​common/​scm.ts Exposes structural diff visibility through the service.
src/​vs/​workbench/​contrib/​scm/​browser/​scmViewService.ts Owns and synchronizes workspace visibility preferences.
src/​vs/​workbench/​contrib/​scm/​browser/​scmViewPane.ts Uses service-owned visibility state.
src/​vs/​workbench/​contrib/​scm/​browser/​scmStructuralDiffRenderer.ts Generalizes rendering and reuses the navigation helper.
src/​vs/​workbench/​contrib/​scm/​browser/​media/​scmStructuralDiff.css Adds reusable structural row styles.
src/​vs/​workbench/​contrib/​scm/​browser/​media/​scm.css Removes styles moved to the shared stylesheet.
src/​vs/​editor/​test/​browser/​widget/​multiDiffEditorWidget.test.ts Adds range-reveal regression coverage.
src/​vs/​editor/​common/​multiDiffEditor.ts Documents which document reveal ranges reference.
src/​vs/​editor/​browser/​widget/​multiDiffEditor/​multiDiffEditorWidgetImpl.ts Coordinates list scrolling, deferred reveals, and inline range mapping.
src/​vs/​editor/​browser/​widget/​multiDiffEditor/​multiDiffEditorWidget.ts Adds explicit document-side reveal options.
src/​vs/​editor/​browser/​widget/​multiDiffEditor/​diffEditorItemTemplate.ts Calculates reveal offsets and preserves vertical scrolling.
src/​vs/​editor/​browser/​widget/​diffEditor/​utils.ts Accepts readonly position mappings.
src/​vs/​editor/​browser/​widget/​diffEditor/​diffEditorWidget.ts Exposes true-inline rendering state.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 17940495 Current: ce06392a

Changed (1)

chat/chatSubagentContent/ThinkingAcrossCompletion/Light
Before After
before after

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants