From 4d32adfb3f11c4deb8bd258a2f3aa549aa354e60 Mon Sep 17 00:00:00 2001 From: tyfkda Date: Fri, 5 Aug 2016 08:52:38 +0900 Subject: [PATCH] Insert string when it is committed `inputMethodTextChanged` is called every time when a user is modifying a text on input method support. In the time, code haven't modified yet. Code is modified when the user pressed enter key to decide the input, and only the time `committedCount` becomes non zero. --- .../app/syntax/im/InputMethodSupport.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/processing/app/syntax/im/InputMethodSupport.java b/app/src/processing/app/syntax/im/InputMethodSupport.java index e148e5d73a..ff62c6b597 100644 --- a/app/src/processing/app/syntax/im/InputMethodSupport.java +++ b/app/src/processing/app/syntax/im/InputMethodSupport.java @@ -184,15 +184,17 @@ public void inputMethodTextChanged(InputMethodEvent event) { } if (text != null) { - char[] insertion = new char[committedCount]; - char c = text.first(); - for (int i = 0; i < committedCount; i++) { - insertion[i] = c; - c = text.next(); + if (committedCount > 0) { + char[] insertion = new char[committedCount]; + char c = text.first(); + for (int i = 0; i < committedCount; i++) { + insertion[i] = c; + c = text.next(); + } + // Insert this as a compound edit + textArea.setSelectedText(new String(insertion), true); + inputHandler.handleInputMethodCommit(); } - // Insert this as a compound edit - textArea.setSelectedText(new String(insertion), true); - inputHandler.handleInputMethodCommit(); CompositionTextPainter compositionPainter = textArea.getPainter().getCompositionTextpainter(); if (Base.DEBUG) {