diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index a02a59e8c..3bf8238a8 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1172,8 +1172,7 @@ public class LatinIME extends InputMethodService (mJustRevertedSeparator == null || mJustRevertedSeparator.length() == 0 || mJustRevertedSeparator.charAt(0) != primaryCode)) { - pickDefaultSuggestion(); - pickedDefault = true; + pickedDefault = pickDefaultSuggestion(); // Picked the suggestion by the space key. We consider this // as "added an auto space". if (primaryCode == KEYCODE_SPACE) { @@ -1204,8 +1203,8 @@ public class LatinIME extends InputMethodService //else if (TextEntryState.STATE_SPACE_AFTER_ACCEPTED) { doubleSpace(); } - if (pickedDefault && mBestWord != null) { - TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord); + if (pickedDefault) { + TextEntryState.backToAcceptedDefault(); } updateShiftKeyState(getCurrentInputEditorInfo()); if (ic != null) { @@ -1502,7 +1501,7 @@ public class LatinIME extends InputMethodService setCandidatesViewShown(isCandidateStripVisible() || mCompletionOn); } - private void pickDefaultSuggestion() { + private boolean pickDefaultSuggestion() { // Complete any pending candidate query first if (mHandler.hasMessages(MSG_UPDATE_SUGGESTIONS)) { mHandler.removeMessages(MSG_UPDATE_SUGGESTIONS); @@ -1514,7 +1513,9 @@ public class LatinIME extends InputMethodService pickSuggestion(mBestWord); // Add the word to the auto dictionary if it's not a known word checkAddToDictionary(mBestWord, AutoDictionary.FREQUENCY_FOR_TYPED); + return true; } + return false; } public void pickSuggestionManually(int index, CharSequence suggestion) { diff --git a/java/src/com/android/inputmethod/latin/TextEntryState.java b/java/src/com/android/inputmethod/latin/TextEntryState.java index d291af651..e2f949e4b 100644 --- a/java/src/com/android/inputmethod/latin/TextEntryState.java +++ b/java/src/com/android/inputmethod/latin/TextEntryState.java @@ -132,7 +132,20 @@ public class TextEntryState { sState = STATE_ACCEPTED_DEFAULT; LatinImeLogger.logOnAutoSuggestion(typedWord.toString(), actualWord.toString()); } - + + // STATE_ACCEPTED_DEFAULT will be changed to other sub-states + // (see "case STATE_ACCEPTED_DEFAULT" in typedCharacter() below), + // and should be restored back to STATE_ACCEPTED_DEFAULT after processing for each sub-state. + public static void backToAcceptedDefault() { + switch (sState) { + case STATE_SPACE_AFTER_ACCEPTED: + case STATE_PUNCTUATION_AFTER_ACCEPTED: + case STATE_IN_WORD: + sState = STATE_ACCEPTED_DEFAULT; + break; + } + } + public static void acceptedTyped(CharSequence typedWord) { sWordNotInDictionaryCount++; sState = STATE_PICKED_SUGGESTION;