diff options
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java index e7ff12acdf..1a6facaa40 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java @@ -100,6 +100,7 @@ void createWidget () { /** * Returns the offset of the caret from the start of the document. + * -1 means that there is currently no active composition. * The caret is within the current composition. * * @return the caret offset @@ -301,6 +302,19 @@ long gtk_preedit_changed (long imcontext) { byte [] buffer = new byte [length]; C.memmove (buffer, preeditString [0], length); chars = Converter.mbcsToWcs (buffer); + + /* + * Bug 571740: GTK has a bug in 'gtk-im-context-simple' IM context + * which is default. It incorrectly reports 'cursorPos' in bytes + * instead of characters. Somewhere around GTK 3.24.26 this IM + * was reworked and it started sending 'gtk_preedit_changed' where + * it previously did not, causing SWT to step on that old bug. + * If caret's position is already at the end, this will result in + * trying to set caret outside the text. The workaround is to limit + * caret's position. + */ + caretOffset = Math.min(caretOffset, chars.length); + if (pangoAttrs [0] != 0) { int count = 0; long iterator = OS.pango_attr_list_get_iterator (pangoAttrs [0]); |