Skip to content

Show comparisons of several files in the unified diff - #2980

Draft
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:unified-diff-multi-file
Draft

vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:unified-diff-multi-file

Conversation

@vogella

@vogella vogella commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

The unified diff only handled a comparison of a single file, so comparing folders, a project or two commits, for example from the EGit History view, always fell back to the classic compare editor. Such comparisons now open their changed files one at a time in a single editor, with a "File 2 of 3" selector on the diff toolbar to jump between them. Next and Previous continue into the neighbouring file according to the existing end-of-element preference, reusing the dialog of the classic editor, which now shares that code with the unified diff. Finishing all diffs of a file moves on to the next one, binary files stay out of the list, and editors the unified diff opened are closed when it moves on, while editors the user already had open are kept.

The unified diff only handled a comparison of a single file, so comparing
folders, a project or two commits always fell back to the classic compare
editor.

Such comparisons now open their changed files one at a time in a single
editor. A "File 2 of 3" selector on the diff toolbar lists the files, and
Next and Previous continue into the neighbouring file following the
existing end-of-element preference and dialog, which TextMergeViewer and
the unified diff now share. Finishing all diffs of a file moves on to the
next one, and binary files are left out.

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@vogella

vogella commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

@tobiasmelcher WDYT? I personally would prefer a Github like display of all changes in one page but I think that would require significant changes.

Example sc
commit-02-first-file
commit-03-file-selector
commit-04-end-reached
commit-05-second-file
reenshots:

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ± 0      54 suites  ±0   54m 43s ⏱️ - 1m 34s
 4 856 tests +12   4 834 ✅ +12   22 💤 ±0  0 ❌ ±0 
12 459 runs  +36  12 305 ✅ +36  154 💤 ±0  0 ❌ ±0 

Results for commit bd008d0. ± Comparison against base commit aa5a77c.

@tobiasmelcher

Copy link
Copy Markdown
Contributor

Hi Lars,

I tested it on my machine by comparing two entries from the git history. It works quite well and the UI flow is easy to understand. The "End Reached. What would you like to do?" popup is already familiar from the traditional two-way compare and behaves as expected. I vote for this feature, great work. Thanks a lot.

During my tests I ran into the following exception. Is a null check missing in class AnnotationModel?

Exception in thread "Thread-40" java.lang.NullPointerException: Cannot invoke

"org.eclipse.jface.text.source.IAnnotationModel.getAnnotationIterator()" because the return value of "java.util.Map.get(Object)" is null
    at org.eclipse.jface.text.source.AnnotationModel.getAnnotationIterator(AnnotationModel.java:791)
    at org.eclipse.jface.text.source.AnnotationModel.getAnnotationIterator(AnnotationModel.java:712)
    at org.eclipse.jface.text.source.projection.ProjectionSummary.removeSummaries(ProjectionSummary.java:181)
    at org.eclipse.jface.text.source.projection.ProjectionSummary.internalUpdateSummaries(ProjectionSummary.java:159)
    at org.eclipse.jface.text.source.projection.ProjectionSummary$Summarizer.run(ProjectionSummary.java:75)

Regarding your preference to have all diffs on a single page: this is related to what Denis is trying to achieve in #2946 (comment). I also see, however, that it would require a complete re-implementation of the current unified diff, since line-header code minings are only supported in text editors, not in the plain SourceViewers used by the traditional two-way CompareEditor. Let's see how far Denis gets; maybe he finds a good solution to embed the unified diff in the CompareEditor.

With best regards,
Tobias

@vogella

vogella commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

"org.eclipse.jface.text.source.IAnnotationModel.getAnnotationIterator()" because the return value of "java.util.Map.get(Object)" is null
at org.eclipse.jface.text.source.AnnotationModel.getAnnotationIterator(AnnotationModel.java:791)
at org.eclipse.jface.text.source.AnnotationModel.getAnnotationIterator(AnnotationModel.java:712)
at org.eclipse.jface.text.source.projection.ProjectionSummary.removeSummaries(ProjectionSummary.java:181)
at org.eclipse.jface.text.source.projection.ProjectionSummary.internalUpdateSummaries(ProjectionSummary.java:159)
at org.eclipse.jface.text.source.projection.ProjectionSummary$Summarizer.run(ProjectionSummary.java:75)

Thanks I check later.

Regarding your preference to have all diffs on a single page: this is related to what Denis is trying to achieve in #2946 (comment). I also see, however, that it would require a complete re-implementation of the current unified diff, since line-header code minings are only supported in text editors, not in the plain SourceViewers used by the traditional two-way CompareEditor. Let's see how far Denis gets; maybe he finds a good solution to embed the unified diff in the CompareEditor.

My understanding of the issue was that he wants to combine old compare and new in one editor for one file. But as the PR description is not concise, I have problems extracting the gist from it without spending to much time (which I currently do not have). I also think both possible approaches will be very difficult to archive.

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