Skip to content

Commit 4d32adf

Browse files
committed
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.
1 parent 1a67e1d commit 4d32adf

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

app/src/processing/app/syntax/im/InputMethodSupport.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,17 @@ public void inputMethodTextChanged(InputMethodEvent event) {
184184
}
185185

186186
if (text != null) {
187-
char[] insertion = new char[committedCount];
188-
char c = text.first();
189-
for (int i = 0; i < committedCount; i++) {
190-
insertion[i] = c;
191-
c = text.next();
187+
if (committedCount > 0) {
188+
char[] insertion = new char[committedCount];
189+
char c = text.first();
190+
for (int i = 0; i < committedCount; i++) {
191+
insertion[i] = c;
192+
c = text.next();
193+
}
194+
// Insert this as a compound edit
195+
textArea.setSelectedText(new String(insertion), true);
196+
inputHandler.handleInputMethodCommit();
192197
}
193-
// Insert this as a compound edit
194-
textArea.setSelectedText(new String(insertion), true);
195-
inputHandler.handleInputMethodCommit();
196198

197199
CompositionTextPainter compositionPainter = textArea.getPainter().getCompositionTextpainter();
198200
if (Base.DEBUG) {

0 commit comments

Comments
 (0)