aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-01-25 21:24:23 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-01-25 21:24:23 -0800
commit5f859f20a0bfa3b0d6995eb1fc4f3461f07e944d (patch)
tree8cfdebffe41d3ea9c412ea5838a4463b69151c1a /java
parente8ff9e107b4f57da7c7b3d3d6849bf538a5c6e89 (diff)
parent051ac1ef143113df7f8b7b2a693b8c5b8d8c38ca (diff)
downloadlatinime-5f859f20a0bfa3b0d6995eb1fc4f3461f07e944d.tar.gz
latinime-5f859f20a0bfa3b0d6995eb1fc4f3461f07e944d.tar.xz
latinime-5f859f20a0bfa3b0d6995eb1fc4f3461f07e944d.zip
am 051ac1ef: Merge "Add a guard against OOB."
* commit '051ac1ef143113df7f8b7b2a693b8c5b8d8c38ca': Add a guard against OOB.
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 03c0878f9..327950a54 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2229,10 +2229,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final CharSequence textBeforeCursor = ic.getTextBeforeCursor(2, 0);
// NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to
// enter surrogate pairs this code will have been removed.
- if (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1)) {
- // We should not have come here if the text before the cursor is not a space.
- throw new RuntimeException("Tried to revert a swap of punctuation but we didn't "
+ if (TextUtils.isEmpty(textBeforeCursor)
+ || (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1))) {
+ // We may only come here if the application is changing the text while we are typing.
+ // This is quite a broken case, but not logically impossible, so we shouldn't crash,
+ // but some debugging log may be in order.
+ Log.d(TAG, "Tried to revert a swap of punctuation but we didn't "
+ "find a space just before the cursor.");
+ return false;
}
ic.beginBatchEdit();
ic.deleteSurroundingText(2, 0);