diff options
author | 2014-01-08 16:47:21 +0900 | |
---|---|---|
committer | 2014-01-08 17:19:29 +0900 | |
commit | dd3d697a6e6713d82020dd63cbf78e4f87664484 (patch) | |
tree | 837f289c2257dd09e0cbd07a83977e886867ab4e /java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java | |
parent | f628629f69228a4898f60334e89213cd20fdac52 (diff) | |
download | latinime-dd3d697a6e6713d82020dd63cbf78e4f87664484.tar.gz latinime-dd3d697a6e6713d82020dd63cbf78e4f87664484.tar.xz latinime-dd3d697a6e6713d82020dd63cbf78e4f87664484.zip |
Fix a race condition, take 2.
Don't use absolute cursor positions when making edits,
this leads to race conditions.
This is a bit ugly and will need to be fixed soon. Plans are
underway to clean this up.
Bug: 12390573
Change-Id: Ib42d4149343c642b1b5c1937b424e8afdbd4cc1f
Diffstat (limited to 'java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index e0adacd0c..968129a96 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -813,7 +813,8 @@ public final class InputLogic { } } if (settingsValues.isSuggestionStripVisible() - && settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces) { + && settingsValues.mSpacingAndPunctuations.mCurrentLanguageHasSpaces + && !mConnection.isCursorFollowedByWordCharacter(settingsValues)) { restartSuggestionsOnWordTouchedByCursor(settingsValues, deleteCountAtStart - mDeleteCount /* offset */, true /* includeResumedWordInSuggestions */, keyboardSwitcher); @@ -1114,11 +1115,19 @@ public final class InputLogic { keyboardSwitcher.getKeyboard()); mWordComposer.setCursorPositionWithinWord( typedWord.codePointCount(0, numberOfCharsInWordBeforeCursor)); - // TODO: Change these two lines to setComposingRegion(cursorPosition, + // TODO: Change these lines to setComposingRegion(cursorPosition, // cursorPosition + range.getNumberOfCharsInWordAfterCursor()); - mConnection.deleteSurroundingText(numberOfCharsInWordBeforeCursor, - typedWord.length() - numberOfCharsInWordBeforeCursor); - mConnection.setComposingText(typedWord, 1); + if (0 != offset) { + // Backspace was pressed. We are at the end of a word, and we don't know the cursor + // position for sure, so use relative methods. + mConnection.deleteSurroundingText(numberOfCharsInWordBeforeCursor, 0); + mConnection.setComposingText(typedWord, 1); + } else { + // This is recorrection. The cursor position is reasonably reliable, and the cursor + // may be in the middle of a word so use setComposingRegion. + mConnection.setComposingRegion(expectedCursorPosition - numberOfCharsInWordBeforeCursor, + expectedCursorPosition + range.getNumberOfCharsInWordAfterCursor()); + } 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. |