Merge "Don't use the previous word after a non-whitespace separator"

This commit is contained in:
Jean Chalard 2013-12-13 11:53:30 +00:00 committed by Android (Google) Code Review
commit 7a904514fb
2 changed files with 14 additions and 1 deletions

View file

@ -1469,6 +1469,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert, ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert,
false /* isBatchMode */); false /* isBatchMode */);
} }
mWordComposer.doubleSpacePeriod();
mKeyboardSwitcher.updateShiftState(); mKeyboardSwitcher.updateShiftState();
return true; return true;
} }

View file

@ -471,7 +471,12 @@ public final class WordComposer {
mCapsCount = 0; mCapsCount = 0;
mDigitsCount = 0; mDigitsCount = 0;
mIsBatchMode = false; mIsBatchMode = false;
mPreviousWord = mTypedWord.toString(); final boolean isWhitespace = 1 == StringUtils.codePointCount(separatorString)
&& Character.isWhitespace(separatorString.codePointAt(0));
// If not whitespace, we don't use the previous word for suggestion. This is consistent
// with how we get the previous word for suggestion: see RichInputConnection#spaceRegex and
// LatinIME#getNthPreviousWordForSuggestion.
mPreviousWord = isWhitespace ? mTypedWord.toString() : null;
mTypedWord.setLength(0); mTypedWord.setLength(0);
mCodePointSize = 0; mCodePointSize = 0;
mTrailingSingleQuotesCount = 0; mTrailingSingleQuotesCount = 0;
@ -485,6 +490,13 @@ public final class WordComposer {
return lastComposedWord; return lastComposedWord;
} }
public void doubleSpacePeriod() {
// When a period was entered with a double space, the separator we got has been
// changed by a period (see #commitWord). We should not use the previous word for
// suggestion.
mPreviousWord = null;
}
public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord, public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord,
final String previousWord) { final String previousWord) {
mPrimaryKeyCodes = lastComposedWord.mPrimaryKeyCodes; mPrimaryKeyCodes = lastComposedWord.mPrimaryKeyCodes;