aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 8dce586d7..375eacee3 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -929,14 +929,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final boolean selectionChanged = mLastSelectionStart != newSelStart
|| mLastSelectionEnd != newSelEnd;
+
// if composingSpanStart and composingSpanEnd are -1, it means there is no composing
// span in the view - we can use that to narrow down whether the cursor was moved
// by us or not. If we are composing a word but there is no composing span, then
// we know for sure the cursor moved while we were composing and we should reset
// the state. TODO: rescind this policy: the framework never removes the composing
// span on its own accord while editing. This test is useless.
-
final boolean noComposingSpan = composingSpanStart == -1 && composingSpanEnd == -1;
+
// If the keyboard is not visible, we don't need to do all the housekeeping work, as it
// will be reset when the keyboard shows up anyway.
// TODO: revisit this when LatinIME supports hardware keyboards.
@@ -958,7 +959,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// state-related special processing to kick in.
mSpaceState = SPACE_STATE_NONE;
- if ((!mWordComposer.isComposingWord()) || selectionChanged || noComposingSpan) {
+ // TODO: is it still necessary to test for composingSpan related stuff?
+ final boolean selectionChangedOrSafeToReset = selectionChanged
+ || (!mWordComposer.isComposingWord()) || noComposingSpan;
+ if (selectionChangedOrSafeToReset) {
// If we are composing a word and moving the cursor, we would want to set a
// suggestion span for recorrection to work correctly. Unfortunately, that
// would involve the keyboard committing some new text, which would move the
@@ -969,6 +973,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// text, but that is probably too expensive to do, so we decided to leave things
// as is.
resetEntireInputState(newSelStart);
+ } else {
+ // resetEntireInputState calls resetCachesUponCursorMove, but with the second
+ // argument as true. But in all cases where we don't reset the entire input state,
+ // we still want to tell the rich input connection about the new cursor position so
+ // that it can update its caches.
+ mConnection.resetCachesUponCursorMove(newSelStart,
+ false /* shouldFinishComposition */);
}
// We moved the cursor. If we are touching a word, we need to resume suggestion,
@@ -976,7 +987,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (isSuggestionsStripVisible()) {
mHandler.postResumeSuggestions();
}
- mConnection.userMovedCursor(newSelEnd);
// Reset the last recapitalization.
mRecapitalizeStatus.deactivate();
mKeyboardSwitcher.updateShiftState();