Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2013-05-06 16:58:51 +0000
committerSilenio Quarti2013-05-06 16:58:51 +0000
commitc344dba8cb6458ad0164d542d97fb40c8ff638c8 (patch)
treeb604d317dfcaf3f366f3c61e74e82efdf5f9be36
parentf1f45c74fe38a901552d12f65eebf46b85a192dd (diff)
downloadeclipse.platform.swt-c344dba8cb6458ad0164d542d97fb40c8ff638c8.tar.gz
eclipse.platform.swt-c344dba8cb6458ad0164d542d97fb40c8ff638c8.tar.xz
eclipse.platform.swt-c344dba8cb6458ad0164d542d97fb40c8ff638c8.zip
Bug 406623 - [DBCS4.3]: The first character in empty StyledText is duplicated when using custom StyledTextContent
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java1
2 files changed, 4 insertions, 8 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 480b18914e..b790cdf2ae 100644
--- 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
@@ -5792,6 +5792,9 @@ void handleCompositionChanged(Event event) {
String text = event.text;
int start = event.start;
int end = event.end;
+ int charCount = content.getCharCount();
+ start = Math.min(start, charCount);
+ end = Math.min(end, charCount);
int length = text.length();
if (length == ime.getCommitCount()) {
content.replaceTextRange(start, end - start, "");
@@ -7814,14 +7817,6 @@ void reset() {
if (horizontalBar != null) {
horizontalBar.setSelection(0);
}
- if (ime != null) {
- String text = ime.getText();
- if (text != null && text.length() > 0 && ime.getCompositionOffset() != -1) {
- ime.setCompositionOffset(0);
- content.replaceTextRange(0, 0, text);
- setCaretOffset(ime.getCaretOffset(), SWT.DEFAULT);
- }
- }
resetCache(0, 0);
setCaretLocation();
super.redraw();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
index f3ce6d2e24..3a441c092c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
@@ -941,6 +941,7 @@ TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpac
int end = imeRanges[i*2+1] - lineOffset;
TextStyle imeStyle = imeStyles[i], userStyle;
for (int j = start; j <= end; j++) {
+ if (!(0 <= j && j < length)) break;
userStyle = layout.getStyle(j);
if (userStyle == null && j > 0) userStyle = layout.getStyle(j - 1);
if (userStyle == null && j + 1 < length) userStyle = layout.getStyle(j + 1);

Back to the top