Skip to content

Do not leave an editor behind when the unified diff falls back - #2853

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:compare-close-stray-unified-editor
Aug 7, 2026
Merged

Do not leave an editor behind when the unified diff falls back#2853
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:compare-close-stray-unified-editor

Conversation

@vogella

@vogella vogella commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Opening the unified diff opens the text editor first and only then finds out whether the diff can be applied at all: the editor registered for the file may not be a text editor, or applying the diff may fail. In those cases the classic compare editor takes over, but the editor opened a moment earlier stayed open, so the user ended up with two editors on the same file, one of them without any comparison in it.

An editor opened by this code is now closed again before falling back, while one that was already open is left alone. The two are told apart by comparing the part openEditor returns with the one found beforehand, rather than by asking twice whether an editor exists. On the fallback path the editor briefly becomes visible before it closes again; avoiding that would mean knowing the part type without opening it.

The regression test registers a deliberately non-text editor for a test-only file extension, so the fallback is reproducible without depending on which editors happen to be in the target platform. A second test covers the other direction, that an editor the user already had open survives.

Contributes to #2795

Opening the unified diff opens the text editor first and only then finds
out whether the diff can be applied at all: the editor registered for the
file may not be a text editor, or applying the diff may fail. In those
cases the classic compare editor takes over, but the editor opened a
moment earlier stayed open, so the user ended up with two editors on the
same file, one of them without any comparison in it. That is what happens
for file types whose default editor is not a text editor.

An editor opened by this code is now closed again before falling back. One
that was already open is left alone, and it is recognized by comparing the
part openEditor returns with the one found beforehand, rather than by
asking twice whether an editor exists.

On the fallback path the editor briefly becomes visible before it closes
again. Avoiding that would mean knowing the part type without opening it.
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   57m 34s ⏱️ - 2m 26s
 4 707 tests +2   4 685 ✅ +2   22 💤 ±0  0 ❌ ±0 
12 012 runs  +6  11 859 ✅ +6  153 💤 ±0  0 ❌ ±0 

Results for commit 8c8aeb6. ± Comparison against base commit 1ab1f7e.

@vogella
vogella merged commit 1cc9ae4 into eclipse-platform:master Aug 7, 2026
18 checks passed
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