Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2013-01-08 17:59:52 +0000
committerDani Megert2013-01-08 17:59:52 +0000
commit13831cac760c363d14333afea22515125cd81252 (patch)
tree4233af566acff80ed19adca93395853187a304c1
parent90646e23eaab9e5eb6abdf0f21f5bcb779d6bfd8 (diff)
downloadeclipse.platform.text-13831cac760c363d14333afea22515125cd81252.tar.gz
eclipse.platform.text-13831cac760c363d14333afea22515125cd81252.tar.xz
eclipse.platform.text-13831cac760c363d14333afea22515125cd81252.zip
Fixed bug 397113: [quick diff] "Delete Added Line" operation fails tov20130108-175952
delete LF at end of file
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
index 5e4b9e658..498b80d0c 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -281,6 +281,11 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
QuickDiffRangeDifference diff= region.getDifference();
int rOffset= fRightDocument.getLineOffset(line);
int rLength= fRightDocument.getLineLength(line);
+ if (line > 0 && line == fRightDocument.getNumberOfLines() - 1) {
+ int lineDelimLength= fRightDocument.getLineDelimiter(line - 1).length();
+ rLength= rLength + lineDelimLength;
+ rOffset= rOffset - lineDelimLength;
+ }
int leftLine= diff.leftStart() + region.getOffset();
String replacement;
if (leftLine >= diff.leftEnd()) // restoring a deleted line?
@@ -307,8 +312,25 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
QuickDiffRangeDifference diff= region.getDifference();
int rOffset= fRightDocument.getLineOffset(diff.rightStart());
int rLength= fRightDocument.getLineOffset(diff.rightEnd() - 1) + fRightDocument.getLineLength(diff.rightEnd() - 1) - rOffset;
- int lOffset= fLeftDocument.getLineOffset(diff.leftStart());
- int lLength= fLeftDocument.getLineOffset(diff.leftEnd() - 1) + fLeftDocument.getLineLength(diff.leftEnd() - 1) - lOffset;
+ int leftStartLine= diff.leftStart();
+ int lOffset;
+ if (leftStartLine < fLeftDocument.getNumberOfLines())
+ lOffset= fLeftDocument.getLineOffset(leftStartLine);
+ else {
+ lOffset= fLeftDocument.getLineOffset(leftStartLine - 1) + fLeftDocument.getLineLength(leftStartLine - 1);
+ String lineDelim= fRightDocument.getLineDelimiter(diff.leftEnd());
+ int lineDelimLength= lineDelim != null ? lineDelim.length() : 0;
+ rOffset= rOffset - lineDelimLength;
+ rLength= rLength + lineDelimLength;
+ }
+
+ int leftEndLine= diff.leftEnd();
+ int lLength;
+ if (leftEndLine > 0)
+ lLength= fLeftDocument.getLineOffset(diff.leftEnd() - 1) + fLeftDocument.getLineLength(diff.leftEnd() - 1) - lOffset;
+ else
+ lLength= fLeftDocument.getLength() - lOffset;
+
fRightDocument.replace(rOffset, rLength, fLeftDocument.get(lOffset, lLength));
}

Back to the top