Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalgorzata Janczarska2013-07-09 09:08:03 -0400
committerMalgorzata Janczarska2013-07-09 09:08:03 -0400
commit7b8db75d7e1cb639dafec4c03cd66ba78718e11d (patch)
tree1f62ba548e7845c309ce46857aa16bde8e82ef8f
parent993a62289e5805ed41286af020819cb3f3d2e636 (diff)
downloadeclipse.platform.team-7b8db75d7e1cb639dafec4c03cd66ba78718e11d.tar.gz
eclipse.platform.team-7b8db75d7e1cb639dafec4c03cd66ba78718e11d.tar.xz
eclipse.platform.team-7b8db75d7e1cb639dafec4c03cd66ba78718e11d.zip
Bug 412579 - [Backport][Edit] "Copy Current from Right to Left" doesn'tM20130724-0800M20130717-0800M20130710-0800
work when triggered after Undo
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java53
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java2
2 files changed, 51 insertions, 4 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index b1db00552..3492dbd31 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -433,6 +433,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private DocumentMerger fMerger;
/** The current diff */
private Diff fCurrentDiff;
+ private Diff fSavedDiff;
// Bug 259362 - Update diffs after undo
private boolean copyOperationInProgress = false;
@@ -3007,11 +3008,17 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
}
if (!isLeftDirty() && !isRightDirty()) {
fRedoDiff = false;
+ final Diff oldDiff = getLastDiff();
new UIJob(CompareMessages.DocumentMerger_0) {
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!getControl().isDisposed()) {
doDiff();
- if (!getControl().isDisposed()) { // doDiff() might have closed the editor
+ if (!getControl().isDisposed()) {
+ Diff newDiff = findNewDiff(oldDiff);
+ if (newDiff != null) {
+ updateStatus(newDiff);
+ setCurrentDiff(newDiff, true);
+ }
invalidateLines();
updateLines(doc);
}
@@ -3024,6 +3031,43 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
}
}
+
+ private void saveDiff() {
+ fSavedDiff = fCurrentDiff;
+ }
+
+ private Diff getLastDiff() {
+ if (fCurrentDiff != null) {
+ return fCurrentDiff;
+ }
+ return fSavedDiff;
+ }
+
+
+ private Diff findNewDiff(Diff oldDiff) {
+ if (oldDiff == null)
+ return null;
+ Diff newDiff = findNewDiff(oldDiff, LEFT_CONTRIBUTOR);
+ if (newDiff == null) {
+ newDiff = findNewDiff(oldDiff, RIGHT_CONTRIBUTOR);
+ }
+ return newDiff;
+ }
+
+ private Diff findNewDiff(Diff oldDiff, char type) {
+ int offset = oldDiff.getPosition(type).offset;
+ int length = oldDiff.getPosition(type).length;
+
+ // DocumentMerger.findDiff method doesn't really work well with 0-length
+ // diffs
+ if (length == 0) {
+ if (offset > 0)
+ offset--;
+ length = 1;
+ }
+ return fMerger.findDiff(type, offset, offset + length);
+ }
+
/*
* This method is called if a range of text on one side is copied into an empty sub-document
* on the other side. The method returns the position where the sub-document is placed into the base document.
@@ -3336,7 +3380,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
fAncestor.resetLineBackground();
fLeft.resetLineBackground();
fRight.resetLineBackground();
-
+ saveDiff();
fCurrentDiff= null;
try {
fMerger.doDiff();
@@ -4637,9 +4681,11 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
}
// now switch diffs
+ saveDiff();
fCurrentDiff= d;
revealDiff(d, d.isToken());
} else {
+ saveDiff();
fCurrentDiff= d;
}
@@ -4890,7 +4936,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
*/
private boolean copy(Diff diff, boolean leftToRight) {
- if (diff != null && !diff.isResolved()) {
+ if (diff != null) {
if (!validateChange(!leftToRight))
return false;
if (leftToRight) {
@@ -5222,6 +5268,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private void resetDiffs() {
// clear stuff
+ saveDiff();
fCurrentDiff= null;
fMerger.reset();
resetPositions(fLeft.getSourceViewer().getDocument());
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
index c961c8028..ef7bf0223 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
@@ -1258,7 +1258,7 @@ public class DocumentMerger {
*/
public boolean copy(Diff diff, boolean leftToRight) {
- if (diff != null && !diff.isResolved()) {
+ if (diff != null) {
Position fromPos= null;
Position toPos= null;
IDocument fromDoc= null;

Back to the top