Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,11 @@ protected IStatus run(IProgressMonitor monitor) {
}
Display.getDefault().asyncExec(() -> {
IEditorPart compareEditor = wpage.findEditor(input);
if (openUnifiedDiff(source, input, wpage, null, true) && compareEditor != null) {
if (compareEditor == null) {
// The comparison was closed while it was being prepared.
return;
}
if (openUnifiedDiff(source, input, wpage, null, true)) {
// Prompts when the merge has unsaved changes.
wpage.closeEditor(compareEditor, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
Expand Down Expand Up @@ -621,7 +622,27 @@ public void testSwitchToUnifiedDiffReplacesTheCompareEditor() throws Exception {
"switching must reuse the already prepared input"); //$NON-NLS-1$
}

/** A missing resource key would leave the toolbar button blank. */
/**
* A comparison the user closed while the switch was being prepared must not
* bring up an editor afterwards.
*/
@Test
public void testSwitchToUnifiedDiffStopsWhenTheComparisonIsClosed() throws Exception {
RecordingCompareEditorInput input = openClassicInput();

CompareUIPlugin.getDefault().switchToUnifiedDiff(input, activePage());
// Still on the display thread, so this lands before the switch can open
// anything.
activePage().closeEditor(activePage().findEditor(input), false);

pumpUntil(() -> Job.getJobManager().find(input).length == 0, "the switch job did not finish"); //$NON-NLS-1$
processQueuedEvents();

assertEquals(0, activePage().getEditorReferences().length,
"no editor may open once the comparison is closed"); //$NON-NLS-1$
}

/** A missing resource key would label the toolbar button with the key itself. */
@Test
public void testShowUnifiedDiffActionIsFullyDescribed() {
ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.compare.contentmergeviewer.TextMergeViewerResources", //$NON-NLS-1$
Expand All @@ -631,7 +652,10 @@ public void testShowUnifiedDiffActionIsFullyDescribed() {
};
Utilities.initAction(action, bundle, "action.ShowUnifiedDiff."); //$NON-NLS-1$

assertEquals("Show Unified Diff", action.getText(), "the action needs a label"); //$NON-NLS-1$ //$NON-NLS-2$
// A failed lookup yields the key, so the label is checked against that rather
// than against the English text, which a translation would replace.
assertNotEquals("action.ShowUnifiedDiff.label", action.getText(), "the action needs a label"); //$NON-NLS-1$ //$NON-NLS-2$
assertFalse(action.getText().isBlank(), "the action needs a label"); //$NON-NLS-1$
assertNotNull(action.getToolTipText(), "the action needs a tooltip"); //$NON-NLS-1$
assertNotNull(action.getImageDescriptor(), "the action needs an icon"); //$NON-NLS-1$
}
Expand Down
Loading