aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-12-13 17:40:06 +0900
committerJean Chalard <jchalard@google.com>2011-12-13 17:40:06 +0900
commit8ad4013406e5e94967bb74baae3b068187f62e4b (patch)
tree0b18c4952f0e3d5544e72c0e284cd2921cf0aa6c /java/src
parent0a2494fa5881152a9ed316409ae650353d8969fb (diff)
downloadlatinime-8ad4013406e5e94967bb74baae3b068187f62e4b.tar.gz
latinime-8ad4013406e5e94967bb74baae3b068187f62e4b.tar.xz
latinime-8ad4013406e5e94967bb74baae3b068187f62e4b.zip
Tighten conditions for space-related cancelling
Instead of ignoring silently a found bug, throw an exception. Change-Id: I0aa96d0cab022b6a5e7cffe8a592dcc443c3c7a8
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index a67e4c938..596828ede 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2226,8 +2226,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// Here we test whether we indeed have a period and a space before us. This should not
// be needed, but it's there just in case something went wrong.
final CharSequence textBeforeCursor = ic.getTextBeforeCursor(2, 0);
- if (!". ".equals(textBeforeCursor))
- return false;
+ if (!". ".equals(textBeforeCursor)) {
+ // We should not have come here if we aren't just after a ". ".
+ throw new RuntimeException("Tried to revert double-space combo but we didn't find "
+ + "\". \" just before the cursor.");
+ }
ic.beginBatchEdit();
ic.deleteSurroundingText(2, 0);
ic.commitText(" ", 1);
@@ -2241,8 +2244,11 @@ 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))
- return false;
+ 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 punctiation but we didn't "
+ + "find a space just before the cursor.");
+ }
ic.beginBatchEdit();
ic.deleteSurroundingText(2, 0);
ic.commitText(" " + textBeforeCursor.subSequence(0, 1), 1);