aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-12-12 20:30:23 +0900
committerJean Chalard <jchalard@google.com>2011-12-12 21:27:16 +0900
commit5c3ff4c9c86e073d994ad874abe9dae7a665d5c4 (patch)
tree83c71b19fd3cafe1a441df67b4c5c1b723fe45e8 /java/src/com/android/inputmethod/latin/LatinIME.java
parentdcf8a6b2c6bf746c2d633e5c7d3e9692c886df91 (diff)
downloadlatinime-5c3ff4c9c86e073d994ad874abe9dae7a665d5c4.tar.gz
latinime-5c3ff4c9c86e073d994ad874abe9dae7a665d5c4.tar.xz
latinime-5c3ff4c9c86e073d994ad874abe9dae7a665d5c4.zip
Fix a bug where revert auto-correct would revert too much
If there are no uncommitted chars, we shouldn't enter any of the tests that follow. We didn't use to, but a change today made it possible - it should not happen. There is no point in doing the rest of the tests, they are sure to fail. Change-Id: I580dd104aff3585de72a93b38989bfd9713f615b
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java32
1 files changed, 24 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index b68d48246..e34bdc751 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1374,6 +1374,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mKeyboardSwitcher.updateShiftState();
mKeyboardSwitcher.onCodeInput(Keyboard.CODE_DUMMY);
mSpaceState = SPACE_STATE_NONE;
+ mWordSavedForAutoCorrectCancellation = null;
mEnteredText = text;
}
@@ -1392,6 +1393,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mVoiceProxy.handleBackspace();
+ if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
+ // Cancel multi-character input: remove the text we just entered.
+ // This is triggered on backspace after a key that inputs multiple characters,
+ // like the smiley key or the .com key.
+ ic.deleteSurroundingText(mEnteredText.length(), 0);
+ // If we have mEnteredText, then we know that mHasUncommittedTypedChars == false.
+ // In addition we know that spaceState is false, and that we should not be
+ // reverting any autocorrect at this point. So we can safely return.
+ ic.endBatchEdit();
+ return;
+ }
+
final boolean deleteChar = !mHasUncommittedTypedChars;
if (mHasUncommittedTypedChars) {
final int length = mWordComposer.size();
@@ -1417,6 +1430,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} else {
ic.deleteSurroundingText(1, 0);
}
+ // If we deleted the last remaining char of a word, we may have to put the keyboard
+ // in auto-shift state again.
+ mHandler.postUpdateShiftKeyState();
+ // If we had uncommitted chars then we know it's not time to revert any auto-correct
+ // and that spaceState is NONE.
+ ic.endBatchEdit();
+ return;
}
mHandler.postUpdateShiftKeyState();
@@ -1445,12 +1465,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
}
- if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
- // Cancel multi-character input: remove the text we just entered.
- // This is triggered on backspace after a key that inputs multiple characters,
- // like the smiley key or the .com key.
- ic.deleteSurroundingText(mEnteredText.length(), 0);
- } else if (deleteChar) {
+ if (deleteChar) {
if (mSuggestionsView != null && mSuggestionsView.dismissAddToDictionaryHint()) {
// Go back to the suggestion mode if the user canceled the
// "Touch again to save".
@@ -1590,6 +1605,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (ic != null) {
ic.beginBatchEdit();
}
+ // Reset the saved word in all cases. If this separator causes an autocorrection,
+ // it will overwrite this null with the actual word we need to save.
+ mWordSavedForAutoCorrectCancellation = null;
if (mHasUncommittedTypedChars) {
// In certain languages where single quote is a separator, it's better
// not to auto correct, but accept the typed word. For instance,
@@ -1602,8 +1620,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} else {
commitTyped(ic);
}
- } else {
- mWordSavedForAutoCorrectCancellation = null;
}
final boolean swapMagicSpace;