aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-01-17 14:58:27 +0900
committerJean Chalard <jchalard@google.com>2012-01-17 15:50:18 +0900
commitfbd1ac80838abb47bca25203f05de3a364356f27 (patch)
tree1ef1ae24b27078c64983e35b2161e7e0cfa1d9df /java/src
parenta8ba49c2534220105ce302a50b3a9ddaf831ef20 (diff)
downloadlatinime-fbd1ac80838abb47bca25203f05de3a364356f27.tar.gz
latinime-fbd1ac80838abb47bca25203f05de3a364356f27.tar.xz
latinime-fbd1ac80838abb47bca25203f05de3a364356f27.zip
Fix a bug where suggestion would restart at a bad time
Bug: 5846646 Change-Id: I7c907d0a9478e0878b92ead94173caefc21b627b
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java19
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 e6c4ba71b..820b2e638 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2089,10 +2089,23 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
&& !mSettingsValues.isWordSeparator(textAfterCursor.charAt(0))) return;
// Bail out if word before cursor is 0-length or a single non letter (like an apostrophe)
- // Example: " '|" gets rejected here but "I'|" and "I|" are okay
- final CharSequence word = EditingUtils.getWordAtCursor(ic, mSettingsValues.mWordSeparators);
+ // Example: " -|" gets rejected here but "e-|" and "e|" are okay
+ CharSequence word = EditingUtils.getWordAtCursor(ic, mSettingsValues.mWordSeparators);
+ // We don't suggest on leading single quotes, so we have to remove them from the word if
+ // it starts with single quotes.
+ while (!TextUtils.isEmpty(word) && Keyboard.CODE_SINGLE_QUOTE == word.charAt(0)) {
+ word = word.subSequence(1, word.length());
+ }
if (TextUtils.isEmpty(word)) return;
- if (word.length() == 1 && !Character.isLetter(word.charAt(0))) return;
+ final char firstChar = word.charAt(0); // we just tested that word is not empty
+ if (word.length() == 1 && !Character.isLetter(firstChar)) return;
+
+ // We only suggest on words that start with a letter or a symbol that is excluded from
+ // word separators (see #handleCharacterWhileInBatchEdit).
+ if (!(isAlphabet(firstChar)
+ || mSettingsValues.isSymbolExcludedFromWordSeparators(firstChar))) {
+ return;
+ }
// Okay, we are at the end of a word. Restart suggestions.
restartSuggestionsOnWordBeforeCursor(ic, word);