From f2f971531904026663a98629eec6eccf83e32faf Mon Sep 17 00:00:00 2001 From: Jean Chalard <jchalard@google.com> Date: Mon, 1 Aug 2011 19:06:54 +0900 Subject: [PATCH] Try to compensate for a race condition. This does not really fix the underlying bug, but it does fix the apparent symptoms. When the user presses space and a letter quick, the onUpdateSelection handler may be called after the letter has been actually committed. The keyboard then happily proceeds to clearing the composition because it thinks space was pressed (or the user moved the cursor, since it can't guess which happened). This change removes this behavior when we are expecting an update event from a keypress. This means the bug still exists if the user presses space twice and a letter, and all events come after the letter, but it is very very hard to reproduce this. There may be other collateral damage when the user moves the cursor in the form of race conditions, but likewise, they should be really hard to reproduce. Bug: 5100521 Change-Id: Ib05328c9b451bf6fe288ae00296fd283a9a4e863 --- java/src/com/android/inputmethod/latin/LatinIME.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 225c7c8995..634801859f 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -789,7 +789,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final boolean selectionChanged = (newSelStart != candidatesEnd || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; - if (((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars) + if (!mExpectingUpdateSelection + && ((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars) || mVoiceProxy.isVoiceInputHighlighted()) && (selectionChanged || candidatesCleared)) { if (candidatesCleared) { @@ -807,7 +808,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar setPunctuationSuggestions(); } TextEntryState.reset(); - InputConnection ic = getCurrentInputConnection(); + final InputConnection ic = getCurrentInputConnection(); if (ic != null) { ic.finishComposingText(); } -- GitLab