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 where the unified diff is opened.
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 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.

Still a draft for one reason: reusing the projection model means this only takes effect in editors that install projection support, such as the Java editor or the Generic Editor. AbstractDecoratedTextEditor and TextEditor do not, so for a plain text file opened with the default text editor the option is silently a no-op. That needs a decision before this lands: accept it as a limitation, or fall back to something that does not depend on projection.

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
@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   58m 35s ⏱️ - 1m 25s
 4 705 tests ±0   4 683 ✅ ±0   22 💤 ±0  0 ❌ ±0 
12 006 runs  ±0  11 853 ✅ ±0  153 💤 ±0  0 ❌ ±0 

Results for commit 909ab3f. ± Comparison against base commit 1ab1f7e.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the unified-diff-fold-unchanged branch 3 times, most recently from a8e0a30 to 0c90f6e Compare July 31, 2026 09:08
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 0c90f6e to 909ab3f Compare August 4, 2026 18:43
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