diff options
author | 2013-12-13 08:34:15 -0800 | |
---|---|---|
committer | 2013-12-13 08:34:15 -0800 | |
commit | 30db835b290cb88ea361fcc96ec53f799a95a6b2 (patch) | |
tree | 3394da0b5ddfee6b25363b401483e9f5df49192f | |
parent | 3ac8ec6b03c59621b316975e38e2bd5352e59786 (diff) | |
parent | 7a904514fb576b41dc94328aec3b04818fad2b4d (diff) | |
download | latinime-30db835b290cb88ea361fcc96ec53f799a95a6b2.tar.gz latinime-30db835b290cb88ea361fcc96ec53f799a95a6b2.tar.xz latinime-30db835b290cb88ea361fcc96ec53f799a95a6b2.zip |
am 7a904514: Merge "Don\'t use the previous word after a non-whitespace separator"
* commit '7a904514fb576b41dc94328aec3b04818fad2b4d':
Don't use the previous word after a non-whitespace separator
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 1 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/WordComposer.java | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 96b1f942d..8b466559c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1469,6 +1469,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert, false /* isBatchMode */); } + mWordComposer.doubleSpacePeriod(); mKeyboardSwitcher.updateShiftState(); return true; } diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 2f81d15d5..5ecfc67b2 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -471,7 +471,12 @@ public final class WordComposer { mCapsCount = 0; mDigitsCount = 0; 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); mCodePointSize = 0; mTrailingSingleQuotesCount = 0; @@ -485,6 +490,13 @@ public final class WordComposer { 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, final String previousWord) { mPrimaryKeyCodes = lastComposedWord.mPrimaryKeyCodes; |