From ee0ffc0c1bf96f679a31f66890d19720c01f05c6 Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Thu, 27 Sep 2012 12:59:30 -0400 Subject: Bug 383392 - StyledText throws exception Index out of bounds when calling setText() after Chinese character input --- .../common/org/eclipse/swt/custom/StyledText.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 41a9db9c76..041e97386c 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 @@ -7794,6 +7794,14 @@ 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(); -- cgit