aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-09-20 03:53:07 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-20 03:53:07 -0700
commit2e10784102868aaccdb91e1822e386a379da3286 (patch)
tree14f5db6ea266ee716bc98f28f86ca207e289ee18 /java/src
parent21915c4cefe17c4325ef46ac05ccee2b8d31009b (diff)
parentbe3be424a38ecb46bb24423be42ad290e896c6cc (diff)
downloadlatinime-2e10784102868aaccdb91e1822e386a379da3286.tar.gz
latinime-2e10784102868aaccdb91e1822e386a379da3286.tar.xz
latinime-2e10784102868aaccdb91e1822e386a379da3286.zip
am be3be424: Fix a bug that happens upon a race condition
* commit 'be3be424a38ecb46bb24423be42ad290e896c6cc': Fix a bug that happens upon a race condition
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java1
-rw-r--r--java/src/com/android/inputmethod/latin/utils/TextRange.java4
2 files changed, 5 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index dead53032..c9311a6d8 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2746,6 +2746,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final TextRange range = mConnection.getWordRangeAtCursor(currentSettings.mWordSeparators,
0 /* additionalPrecedingWordsCount */);
if (null == range) return; // Happens if we don't have an input connection at all
+ if (range.length() <= 0) return; // Race condition. No text to resume on, so bail out.
// If for some strange reason (editor bug or so) we measure the text before the cursor as
// longer than what the entire text is supposed to be, the safe thing to do is bail out.
final int numberOfCharsInWordBeforeCursor = range.getNumberOfCharsInWordBeforeCursor();
diff --git a/java/src/com/android/inputmethod/latin/utils/TextRange.java b/java/src/com/android/inputmethod/latin/utils/TextRange.java
index 5793e4170..48b443ddd 100644
--- a/java/src/com/android/inputmethod/latin/utils/TextRange.java
+++ b/java/src/com/android/inputmethod/latin/utils/TextRange.java
@@ -40,6 +40,10 @@ public final class TextRange {
return mWordAtCursorEndIndex - mCursorIndex;
}
+ public int length() {
+ return mWord.length();
+ }
+
/**
* Gets the suggestion spans that are put squarely on the word, with the exact start
* and end of the span matching the boundaries of the word.