aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/RichInputConnection.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-11-13 14:20:45 +0900
committerThe Android Automerger <android-build@google.com>2013-11-12 22:44:59 -0800
commit3a9b2430a56cb2d774070bd8ecd661d0dfb82484 (patch)
treef578d3435ef7c03143d7a3b18bc8fecb5d207a33 /java/src/com/android/inputmethod/latin/RichInputConnection.java
parenta5f5ab84c0d5d37b68c89addb9de5aa4d5ab6ca6 (diff)
downloadlatinime-3a9b2430a56cb2d774070bd8ecd661d0dfb82484.tar.gz
latinime-3a9b2430a56cb2d774070bd8ecd661d0dfb82484.tar.xz
latinime-3a9b2430a56cb2d774070bd8ecd661d0dfb82484.zip
Fix many small nits.
...the interaction of which results in a very bad bug. Bug: 11648854 Change-Id: I774489e384388f187e72b9ac091ab387c5e1a79a
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index c212f9c81..673d1b4c2 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -61,7 +61,7 @@ public final class RichInputConnection {
* cursor may end up after all the keyboard-triggered updates have passed. We keep this to
* compare it to the actual cursor position to guess whether the move was caused by a
* keyboard command or not.
- * It's not really the cursor position: the cursor may not be there yet, and it's also expected
+ * It's not really the cursor position: the cursor may not be there yet, and it's also expected
* there be cases where it never actually comes to be there.
*/
private int mExpectedCursorPosition = INVALID_CURSOR_POSITION; // in chars, not code points
@@ -292,7 +292,11 @@ public final class RichInputConnection {
mCommittedTextBeforeComposingText.length() + mComposingText.length();
// If we have enough characters to satisfy the request, or if we have all characters in
// the text field, then we can return the cached version right away.
- if (cachedLength >= n || cachedLength >= mExpectedCursorPosition) {
+ // However, if we don't have an expected cursor position, then we should always
+ // go fetch the cache again (as it happens, INVALID_CURSOR_POSITION < 0, so we need to
+ // test for this explicitly)
+ if (INVALID_CURSOR_POSITION != mExpectedCursorPosition
+ && (cachedLength >= n || cachedLength >= mExpectedCursorPosition)) {
final StringBuilder s = new StringBuilder(mCommittedTextBeforeComposingText);
// We call #toString() here to create a temporary object.
// In some situations, this method is called on a worker thread, and it's possible