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
main
Jean Chalard 2011-08-01 19:06:54 +09:00
parent e00d44d0c8
commit f2f9715319
1 changed files with 3 additions and 2 deletions

View File

@ -789,7 +789,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final boolean selectionChanged = (newSelStart != candidatesEnd final boolean selectionChanged = (newSelStart != candidatesEnd
|| newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart;
final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1;
if (((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars) if (!mExpectingUpdateSelection
&& ((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars)
|| mVoiceProxy.isVoiceInputHighlighted()) || mVoiceProxy.isVoiceInputHighlighted())
&& (selectionChanged || candidatesCleared)) { && (selectionChanged || candidatesCleared)) {
if (candidatesCleared) { if (candidatesCleared) {
@ -807,7 +808,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
setPunctuationSuggestions(); setPunctuationSuggestions();
} }
TextEntryState.reset(); TextEntryState.reset();
InputConnection ic = getCurrentInputConnection(); final InputConnection ic = getCurrentInputConnection();
if (ic != null) { if (ic != null) {
ic.finishComposingText(); ic.finishComposingText();
} }