aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-12-14 12:20:58 +0900
committerJean Chalard <jchalard@google.com>2011-12-14 16:24:18 +0900
commit514beb0992f646e90af34e5b18f411586c704ace (patch)
tree7685ce905b7f1c0a8619bf662646f0845eac6fe2 /java/src
parentedf4995a3bad3b95a2b4184d47ea4ff890d0de73 (diff)
downloadlatinime-514beb0992f646e90af34e5b18f411586c704ace.tar.gz
latinime-514beb0992f646e90af34e5b18f411586c704ace.tar.xz
latinime-514beb0992f646e90af34e5b18f411586c704ace.zip
Fix a long-standing race condition.
Upon autocorrection, there is visual feedback in the text view that quickly flashes the background of the text that just changed. This fixes a race condition that happens upon autocorrection when typing fast, and that results in flashing one character too far left (typically, the flashing area includes the whitespace before the corrected word and not the last character of the corrected word). This happens because the call to commitCorrection may happen before or after the IPC sent by sendKeyChar, but the arguments are fit only for the case where it arrives first. Change-Id: I9b5442a665aad5a9bc66cd49228075b9056b37fa
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 2d7eed7ab..23abd67a9 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1604,6 +1604,21 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
}
+ if (pickedDefault) {
+ final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull();
+ final String typedWord = mWordComposer.getTypedWord();
+ if (TextUtils.isEmpty(typedWord)) {
+ throw new RuntimeException("We have non-committed chars but the typed word "
+ + "is empty? Impossible! I must commit suicide.");
+ }
+ if (!typedWord.equals(autoCorrection)) {
+ // This will make the correction flash for a short while as a visual clue
+ // to the user that auto-correction happened.
+ InputConnectionCompatUtils.commitCorrection(
+ ic, mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection);
+ }
+ }
+
final boolean swapMagicSpace;
if (Keyboard.CODE_ENTER == primaryCode && (SPACE_STATE_MAGIC == spaceState
|| SPACE_STATE_SWAP_PUNCTUATION == spaceState)) {
@@ -1651,21 +1666,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
Utils.Stats.onSeparator((char)primaryCode, x, y);
- if (pickedDefault) {
- final CharSequence autoCorrection = mWordComposer.getAutoCorrectionOrNull();
- final String typedWord = mWordComposer.getTypedWord();
- if (TextUtils.isEmpty(typedWord)) {
- throw new RuntimeException("We have non-committed chars but the typed word "
- + "is empty? Impossible! I must commit suicide.");
- }
- if (!typedWord.equals(autoCorrection)) {
- // TODO: if the commitCorrection method is not supported by the platform
- // this will do nothing and the correction will not be committed at all. What
- // happens on Froyo/Gingerbread, where this API is not present?
- InputConnectionCompatUtils.commitCorrection(
- ic, mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection);
- }
- }
mKeyboardSwitcher.updateShiftState();
if (ic != null) {
ic.endBatchEdit();