From 5401637a61a6e99f5c6f2c4c40a17919998e56c3 Mon Sep 17 00:00:00 2001 From: Niraj Modi Date: Tue, 15 Dec 2020 14:01:20 +0530 Subject: Bug 552352 - Using SWAP in Compare editor loses changes and dirty status - Back-port fix to 4.7+ branch Change-Id: Ib8566a295544ed6609326fe1474bb488f8e865d1 --- .../compare/contentmergeviewer/ContentMergeViewer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java index a5e82b2d0..ec159b8bf 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -923,6 +923,17 @@ public abstract class ContentMergeViewer extends ContentViewer fSwitchLeftAndRight = new Action() { @Override public void run() { + /* + * Bug 552352: When comparing .txt files with corresponding .txt file editors + * closed and user modifies the content of one of the .txt file in the compare + * view and the compare state becomes 'dirty' and if followed by a 'Swap' + * action, modifications get lost. This data loss is considered a severe + * problem, so to avoid this modified data loss in this scenario, show a + * confirmation dialog to 'save' the file before swapping and let user decide + * and take a call on this. Note: Issue not seen with .java & .properties files. + */ + doSave(null, getInput()); + IPreferenceStore preferences = getCompareConfiguration().getPreferenceStore(); preferences.setValue(ComparePreferencePage.SWAPPED, !getCompareConfiguration().isMirrored()); if (preferences instanceof IPersistentPreferenceStore) { -- cgit v1.2.3