Skip to content

Fold unchanged regions in the unified diff#2791

Draft
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:unified-diff-fold-unchanged
Draft

Fold unchanged regions in the unified diff#2791
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:unified-diff-fold-unchanged

Conversation

@vogella

@vogella vogella commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

This adds folding of unchanged regions to the experimental unified diff overlay, similar to the collapsed unchanged sections in GitHub's diff view.
A new UnifiedDiff.Builder#foldUnchanged(contextLines) option collapses the unchanged gaps between the displayed changes, keeping a few context lines visible around each change; it is enabled with three context lines on both unified diff paths.
Each collapsed region shows a clickable "Expand n unchanged lines" code mining that expands it in place; re-collapsing via the folding ruler brings the expander back.
The implementation reuses the editor's projection (folding) model, so it is a no-op when folding is disabled, and the folds are tagged with a marker annotation so they can be removed on overlay teardown (Hide All Diffs, switching to the 2-way editor, dismissing the last diff) without touching the editor's own structural folds.
This makes reviewing large files with few changes considerably more compact.

Part of eclipse-platform/eclipse.platform.ui#3771

@vogella

vogella commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

This is a draft so that @tobiasmelcher can join in if he wants.

Current state: Folding works but I have no way to unfold.

image

@vogella vogella requested a review from tobiasmelcher July 2, 2026 07:56
Add a foldUnchanged(contextLines) option to UnifiedDiff that collapses the
unchanged gaps between changes, keeping a few context lines around each
change, similar to the unified view on GitHub. It reuses the editor's
projection (folding) model, so it is a no-op when folding is disabled, and
its folds are tagged so they can be removed without touching the editor's
own folds. Each collapsed region shows a clickable "Expand n unchanged
lines" code mining that expands it in place. Enabled with three context
lines on both unified diff paths.
@vogella vogella force-pushed the unified-diff-fold-unchanged branch from 9ab3ed5 to b50fcaf Compare July 2, 2026 08:03
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   59m 14s ⏱️ + 1m 2s
 4 680 tests ±0   4 658 ✅ ±0   22 💤 ±0  0 ❌ ±0 
11 934 runs  ±0  11 781 ✅ ±0  153 💤 ±0  0 ❌ ±0 

Results for commit b50fcaf. ± Comparison against base commit 9ec007a.

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.

1 participant