summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2009-05-26 18:07:30 +0000
committerFelipe Heidrich <fheidric>2009-05-26 18:07:30 +0000
commit2f2704e0d7d19b7098c6f5c3f93c2b26ac0c01da (patch)
treeeb7b211f432d1a48eddee219c859e4d90e46daed
parentce293f6c2c07d8cac35a4721f9aa0d395e2f52ea (diff)
downloadeclipse.platform.swt-2f2704e0d7d19b7098c6f5c3f93c2b26ac0c01da.tar.gz
eclipse.platform.swt-2f2704e0d7d19b7098c6f5c3f93c2b26ac0c01da.tar.xz
eclipse.platform.swt-2f2704e0d7d19b7098c6f5c3f93c2b26ac0c01da.zip
Bug 277442: BlockSelection: Exception and crash while RTL orientation
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 4c301617f6..02280fb39b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -3546,6 +3546,11 @@ String getBlockSelectionText(String delimiter) {
for (int lineIndex = firstLine; lineIndex <= lastLine; lineIndex++) {
int start = getOffsetAtPoint(left, 0, lineIndex, null);
int end = getOffsetAtPoint(right, 0, lineIndex, null);
+ if (start > end) {
+ int temp = start;
+ start = end;
+ end = temp;
+ }
String text = content.getTextRange(start, end - start);
buffer.append(text);
if (lineIndex < lastLine) buffer.append(delimiter);
@@ -4603,8 +4608,14 @@ public int[] getSelectionRanges() {
int index = 0;
for (int lineIndex = firstLine; lineIndex <= lastLine; lineIndex++) {
int start = getOffsetAtPoint(left, 0, lineIndex, null);
+ int end = getOffsetAtPoint(right, 0, lineIndex, null);
+ if (start > end) {
+ int temp = start;
+ start = end;
+ end = temp;
+ }
ranges[index++] = start;
- ranges[index++] = getOffsetAtPoint(right, 0, lineIndex, null) - start;
+ ranges[index++] = end - start;
}
return ranges;
}
@@ -5464,6 +5475,11 @@ void insertBlockSelectionText(char key, int action) {
} else {
end += trailing[0];
}
+ if (start > end) {
+ int temp = start;
+ start = end;
+ end = temp;
+ }
if (start == end && !outOfLine) {
switch (action) {
case ST.DELETE_PREVIOUS:
@@ -7489,6 +7505,11 @@ int sendTextEvent(int left, int right, int lineIndex, String text, boolean fillW
start = end = content.getCharCount();
buffer.append(content.getLineDelimiter());
}
+ if (start > end) {
+ int temp = start;
+ start = end;
+ end = temp;
+ }
if (fillWithSpaces) {
int spacesWidth = left - lineWidth + horizontalScrollOffset - leftMargin;
int spacesCount = spacesWidth / renderer.averageCharWidth;