Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2010-11-18 20:23:52 +0000
committerMarkus Keller2010-11-18 20:23:52 +0000
commit8fe01cedc5dc8b25a000d04e74f44caf800c3de5 (patch)
tree75ca15114e3a8ec343f38bfc9431b8d921a586bd /org.eclipse.text
parent6932e11874306cb1b2d0455bccc8438563eb1f10 (diff)
downloadeclipse.platform.text-8fe01cedc5dc8b25a000d04e74f44caf800c3de5.tar.gz
eclipse.platform.text-8fe01cedc5dc8b25a000d04e74f44caf800c3de5.tar.xz
eclipse.platform.text-8fe01cedc5dc8b25a000d04e74f44caf800c3de5.zip
Bug 329614 comment 6: [linked mode] Incorrect selection and caret position after rename in file
Diffstat (limited to 'org.eclipse.text')
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java b/org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java
index 6446e8ec4..c79124fdc 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/DefaultPositionUpdater.java
@@ -29,9 +29,11 @@ package org.eclipse.jface.text;
* <li>Deleting text which strictly contains the position deletes the position. Note that the
* position is not deleted if its only shrunken to length zero. To delete a position, the
* modification must delete from <i>strictly before</i> to <i>strictly after</i> the position.</li>
- * <li>Replacing text overlapping with the position is considered as a sequence of first deleting
+ * <li>Replacing text contained by the position shrinks or expands the position (but does not shift it),
+ * such that the final position contains the original position and the replacing text.</li>
+ * <li>Replacing text overlapping the position in other ways is considered as a sequence of first deleting
* the replaced text and afterwards inserting the new text. Thus, a position is shrunken and can
- * then be shifted.</li>
+ * then be shifted (if the replaced text overlaps the offset of the position).</li>
* </ul>
* This class can be used as is or be adapted by subclasses. Fields are protected to allow
* subclasses direct access. Because of the frequency with which position updaters are used this is
@@ -46,6 +48,7 @@ public class DefaultPositionUpdater implements IPositionUpdater {
protected Position fPosition;
/** Caches the original state of the investigated position */
protected Position fOriginalPosition= new Position(0, 0);
+
/** Caches the offset of the replaced text */
protected int fOffset;
/** Caches the length of the replaced text */
@@ -151,16 +154,17 @@ public class DefaultPositionUpdater implements IPositionUpdater {
/**
* Adapts the currently investigated position to the replace operation.
- * First it checks whether the change replaces the whole range of the position.
+ * First it checks whether the change replaces only a non-zero range inside the range of the position (including the borders).
* If not, it performs first the deletion of the previous text and afterwards
* the insertion of the new text.
*/
protected void adaptToReplace() {
- if (fPosition.offset == fOffset && fPosition.length == fLength && fPosition.length > 0) {
+ if (fLength > 0
+ && fPosition.offset <= fOffset
+ && fOffset + fLength <= fPosition.offset + fPosition.length) {
- // replace the whole range of the position
- fPosition.length = 0;
+ fPosition.length += fReplaceLength - fLength;
} else {

Back to the top