diff options
author | 2013-12-16 21:41:03 +0900 | |
---|---|---|
committer | 2013-12-16 23:16:02 +0900 | |
commit | 7cd7cf73f4ce6f0e577d6382eb0fc25f60dc63e1 (patch) | |
tree | 078bbfdfdd341a484777ef6dc9f9e97e16eaa002 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | b767715651a914ba2d89142d13e23eaf081d5b13 (diff) | |
download | latinime-7cd7cf73f4ce6f0e577d6382eb0fc25f60dc63e1.tar.gz latinime-7cd7cf73f4ce6f0e577d6382eb0fc25f60dc63e1.tar.xz latinime-7cd7cf73f4ce6f0e577d6382eb0fc25f60dc63e1.zip |
Fix a bug with languages without spaces and predictions
This is simpler and more correct.
Change-Id: I41806d2fc12b4ca25f76e32972b38f91f3d05c2b
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 1f6091e90..72d5435a8 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1469,7 +1469,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert, false /* isBatchMode */); } - mWordComposer.doubleSpacePeriod(); + mWordComposer.discardPreviousWordForSuggestion(); mKeyboardSwitcher.updateShiftState(); return true; } @@ -2567,7 +2567,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (DEBUG) { if (mWordComposer.isComposingWord() || mWordComposer.isBatchMode()) { - final String previousWord = mWordComposer.getPreviousWord(); + final String previousWord = mWordComposer.getPreviousWordForSuggestion(); // TODO: this is for checking consistency with older versions. Remove this when // we are confident this is stable. // We're checking the previous word in the text field against the memorized previous @@ -2581,7 +2581,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } } } - suggest.getSuggestedWords(mWordComposer, mWordComposer.getPreviousWord(), + suggest.getSuggestedWords(mWordComposer, mWordComposer.getPreviousWordForSuggestion(), keyboard.getProximityInfo(), currentSettings.mBlockPotentiallyOffensive, currentSettings.mCorrectionEnabled, additionalFeaturesOptions, sessionId, sequenceNumber, callback); @@ -2824,6 +2824,19 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // strings. mLastComposedWord = mWordComposer.commitWord(commitType, chosenWord, separatorString, prevWord); + final boolean shouldDiscardPreviousWordForSuggestion; + if (0 == StringUtils.codePointCount(separatorString)) { + // Separator is 0-length. Discard the word only if the current language has spaces. + shouldDiscardPreviousWordForSuggestion = + mSettings.getCurrent().mCurrentLanguageHasSpaces; + } else { + // Otherwise, we discard if the separator contains any non-whitespace. + shouldDiscardPreviousWordForSuggestion = + !StringUtils.containsOnlyWhitespace(separatorString); + } + if (shouldDiscardPreviousWordForSuggestion) { + mWordComposer.discardPreviousWordForSuggestion(); + } } private void setPunctuationSuggestions() { |