aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2013-10-14 19:50:50 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-14 19:50:50 -0700
commiteb870b14ecc7b26de37a939d6a661b54078ad08b (patch)
tree5b5feb3e3f476d16e6897977c70ad99583cb17b8 /java/src
parent3a3bbf4a38870ecc42b7f6fbd3a7cae20fe020a7 (diff)
parent34ad4e0879bbaa23a8ac493d174f804f1d81e25b (diff)
downloadlatinime-eb870b14ecc7b26de37a939d6a661b54078ad08b.tar.gz
latinime-eb870b14ecc7b26de37a939d6a661b54078ad08b.tar.xz
latinime-eb870b14ecc7b26de37a939d6a661b54078ad08b.zip
am 34ad4e08: am b9ce8421: mExpectingUpdateSelection was out of sync when nothing to delete.
* commit '34ad4e0879bbaa23a8ac493d174f804f1d81e25b': mExpectingUpdateSelection was out of sync when nothing to delete.
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java34
1 files changed, 24 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 8654f3b63..10f643c49 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1622,8 +1622,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
case Constants.CODE_DELETE:
mSpaceState = SPACE_STATE_NONE;
handleBackspace(spaceState);
- mDeleteCount++;
- mExpectingUpdateSelection = true;
LatinImeLogger.logOnDelete(x, y);
break;
case Constants.CODE_SHIFT:
@@ -2051,6 +2049,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
private void handleBackspace(final int spaceState) {
+ // We revert these in this method if the deletion doesn't happen.
+ mDeleteCount++;
+ mExpectingUpdateSelection = true;
+
// In many cases, we may have to put the keyboard in auto-shift state again. However
// we want to wait a few milliseconds before doing it to avoid the keyboard flashing
// during key repeat.
@@ -2140,8 +2142,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// This should never happen.
Log.e(TAG, "Backspace when we don't know the selection position");
}
- final int lengthToDelete = Character.isSupplementaryCodePoint(
- mConnection.getCodePointBeforeCursor()) ? 2 : 1;
+ final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
+ if (codePointBeforeCursor == Constants.NOT_A_CODE) {
+ // Nothing to delete before the cursor. We have to revert the deletion states
+ // that were updated at the beginning of this method.
+ mDeleteCount--;
+ mExpectingUpdateSelection = false;
+ return;
+ }
+ final int lengthToDelete =
+ Character.isSupplementaryCodePoint(codePointBeforeCursor) ? 2 : 1;
if (mAppWorkAroundsUtils.isBeforeJellyBean() ||
currentSettings.mInputAttributes.isTypeNull()) {
// There are two possible reasons to send a key event: either the field has
@@ -2160,12 +2170,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
true /* shouldUncommitLogUnit */);
}
if (mDeleteCount > DELETE_ACCELERATE_AT) {
- final int lengthToDeleteAgain = Character.isSupplementaryCodePoint(
- mConnection.getCodePointBeforeCursor()) ? 2 : 1;
- mConnection.deleteSurroundingText(lengthToDeleteAgain, 0);
- if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
- ResearchLogger.latinIME_handleBackspace(lengthToDeleteAgain,
- true /* shouldUncommitLogUnit */);
+ final int codePointBeforeCursorToDeleteAgain =
+ mConnection.getCodePointBeforeCursor();
+ if (codePointBeforeCursorToDeleteAgain != Constants.NOT_A_CODE) {
+ final int lengthToDeleteAgain = Character.isSupplementaryCodePoint(
+ codePointBeforeCursorToDeleteAgain) ? 2 : 1;
+ mConnection.deleteSurroundingText(lengthToDeleteAgain, 0);
+ if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
+ ResearchLogger.latinIME_handleBackspace(lengthToDeleteAgain,
+ true /* shouldUncommitLogUnit */);
+ }
}
}
}