Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2016-05-04 09:03:24 -0400
committerTom Schindl2016-05-04 09:03:24 -0400
commit86480427aa1ae11da03f405e6b40306bf18eaaa8 (patch)
tree332e00b8087b4ff95d7e95e7564d8cab1a15f67d
parentc7cadfc21eba4b708441c6b110c85dd31858f604 (diff)
downloadorg.eclipse.efxclipse-86480427aa1ae11da03f405e6b40306bf18eaaa8.tar.gz
org.eclipse.efxclipse-86480427aa1ae11da03f405e6b40306bf18eaaa8.tar.xz
org.eclipse.efxclipse-86480427aa1ae11da03f405e6b40306bf18eaaa8.zip
Bug 492980 - Undo/redo behave wrong in regard of tab-indenting
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
index 59d196846..b4b2ee31d 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
@@ -1150,7 +1150,7 @@ public class StyledTextBehavior {
String replaced = dataBuffer.substring(start,start+length);
getControl().getContent().replaceTextRange(start, length-added, replaced);
- getControl().setCaretOffset(caret + added);
+ getControl().setCaretOffset(selectionOffset == caret ? caret + indentLength : caret + added);
getControl().setSelectionRange(selectionOffset + indentLength, selectionLength + added - indentLength);
}
}
@@ -1179,6 +1179,7 @@ public class StyledTextBehavior {
}
int firstLineDelta = 0;
+ int firstLineSelectionIndent = 0;
int[] removals = new int[lastLine-firstLine];
for (int lineNumber = firstLine; lineNumber < lastLine; lineNumber++) {
@@ -1207,10 +1208,15 @@ public class StyledTextBehavior {
if (lineNumber == firstLine) {
if (selectionOffset > lineStart) {
firstLineDelta = removals[lineNumber-firstLine];
+ firstLineSelectionIndent = selectionOffset - lineStart;
}
}
}
+ int start = selectionOffset - firstLineSelectionIndent;
+ int end = start + selectionLength + firstLineSelectionIndent;
+ String replacedText = dataBuffer.substring(start, end);
+
int removed = 0;
for (int lineNumber = lastLine - 1; lineNumber >= firstLine; lineNumber--) {
@@ -1219,10 +1225,10 @@ public class StyledTextBehavior {
removed += removals[lineNumber-firstLine];
}
- String data = dataBuffer.toString();
+ String newText = dataBuffer.substring(start, end - removed);
- getControl().getContent().setText(data == null ? "" : data); //$NON-NLS-1$
- getControl().setCaretOffset(caret - removed);
+ getControl().getContent().replaceTextRange(start, replacedText.length(), newText);
+ getControl().setCaretOffset(selectionOffset == caret ? caret - firstLineDelta : caret - removed);
getControl().setSelectionRange(selectionOffset - firstLineDelta, selectionLength - removed + firstLineDelta);
}

Back to the top