From 42e83c7f06a1683b27a11564aeb9f3999b10382f Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 7 Jan 2014 15:12:16 +0900 Subject: [PATCH] Fix a race condition. Don't use absolute cursor positions, this leads to race conditions. Bug: 12390573 Change-Id: I6f04f07a46babbc3d51cb94c7eaee21bed242396 --- .../android/inputmethod/latin/inputlogic/InputLogic.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index b365003a5..c867ab3d3 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -1113,8 +1113,11 @@ public final class InputLogic { keyboardSwitcher.getKeyboard()); mWordComposer.setCursorPositionWithinWord( typedWord.codePointCount(0, numberOfCharsInWordBeforeCursor)); - mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor, - expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor()); + // TODO: Change these two lines to setComposingRegion(cursorPosition, + // cursorPosition + range.getNumberOfCharsInWordAfterCursor()); + mConnection.deleteSurroundingText(numberOfCharsInWordBeforeCursor, + typedWord.length() - numberOfCharsInWordBeforeCursor); + mConnection.setComposingText(typedWord, 1); if (suggestions.isEmpty()) { // We come here if there weren't any suggestion spans on this word. We will try to // compute suggestions for it instead.