Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy2020-10-15 11:32:51 +0000
committerSravan Kumar Lakkimsetti2020-10-20 05:38:31 +0000
commit2a9595e067812151c4c2b3df2bbcba7c10ddf3ae (patch)
tree42d0abd12eb7cefd8ef1d3e2de40086204753c71
parent295c626ac806b63ccb889c5db93c576a1a4bf379 (diff)
downloadeclipse.platform.swt-2a9595e067812151c4c2b3df2bbcba7c10ddf3ae.tar.gz
eclipse.platform.swt-2a9595e067812151c4c2b3df2bbcba7c10ddf3ae.tar.xz
eclipse.platform.swt-2a9595e067812151c4c2b3df2bbcba7c10ddf3ae.zip
Bug 427882 - StyledText: IME-related "Argument not valid" error handling keyDown
Change-Id: Ia72701e4210972ae63f02bddaf188f702ebbde37 Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/IME.java11
-rw-r--r--tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug427882_StyledText_IME_IllegalArgument.java62
2 files changed, 73 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/IME.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/IME.java
index 9db5dfbc27..64220dc804 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/IME.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/IME.java
@@ -493,6 +493,17 @@ boolean setMarkedText_selectedRange (long id, long sel, long string, long selRan
}
NSRange range = new NSRange ();
OS.memmove (range, selRange, NSRange.sizeof);
+
+ /*
+ * Bug 427882: There is a macOS bug where it sends
+ * 'setMarkedText:selectedRange:' with 'markedText' that is incorrectly
+ * too short, which results in 'selectedRange.location' being outside it.
+ * If caret's position is already at the end, this will result in trying
+ * to set caret outside the text. The workaround is to correct 'location'
+ * so that it's always within 'markedText'.
+ */
+ range.location = Math.min(range.location, length);
+
caretOffset = (int)range.location;
Event event = new Event ();
event.detail = SWT.COMPOSITION_CHANGED;
diff --git a/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug427882_StyledText_IME_IllegalArgument.java b/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug427882_StyledText_IME_IllegalArgument.java
new file mode 100644
index 0000000000..9fe1317b11
--- /dev/null
+++ b/tests/org.eclipse.swt.tests/ManualTests/org/eclipse/swt/tests/manual/Bug427882_StyledText_IME_IllegalArgument.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Syntevo and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Syntevo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.manual;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug427882_StyledText_IME_IllegalArgument {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display, SWT.SHELL_TRIM);
+ RowLayout layout = new RowLayout(SWT.VERTICAL);
+ layout.fill = true;
+ shell.setLayout(layout);
+
+ new Label(shell, SWT.NONE).setText(
+ "Preparation :\n" +
+ "1) Use macOS\n" +
+ "2) Install keyboard layout:\n" +
+ " Chinese, Simplified | Pinyin\n" +
+ "3) Switch to this keyboard layout\n" +
+ "\n" +
+ "Bug: \n" +
+ "1) Type 'modified' in box below, without quotes\n" +
+ " You should see hieroglyph suggestions as you type.\n" +
+ " This time, word will be typed correctly.\n" +
+ "2) Type 'modifi' and press 1 to accept suggestion.\n" +
+ "3) Type 'modified', SWT will die with 'IllegalArgumentException: Argument not valid'\n" +
+ "\n" +
+ "How to recover original state: \n" +
+ "1) Delete keyboard layout\n" +
+ "2) Reboot macOS\n" +
+ "3) Delete file ~/Library/Dictionaries/DynamicPhraseLexicon_zh_Hans.db\n"
+ );
+
+ new StyledText(shell, SWT.BORDER);
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+}

Back to the top