diff options
author | 2012-06-28 20:10:19 +0900 | |
---|---|---|
committer | 2012-07-02 15:46:03 +0900 | |
commit | 90d300c770b1697af5b715e55fa87d97e22588d2 (patch) | |
tree | 9a1ce1f017e28f1011b709f08da685a8c820c451 /java/src | |
parent | 2631e3b1954eb0f9ddd637f8ad89fd0eff495c77 (diff) | |
download | latinime-90d300c770b1697af5b715e55fa87d97e22588d2.tar.gz latinime-90d300c770b1697af5b715e55fa87d97e22588d2.tar.xz latinime-90d300c770b1697af5b715e55fa87d97e22588d2.zip |
Clarify some code and fix a bug (A41)
The test against hasMainDictionary is a test to know if we should
auto-correct or not. Its result should be recorded in
hasAutoCorrection, not in allowsToBeAutoCorrected.
Actually, this value being inserted in allowsToBeAutoCorrected was
causing a bug that nobody noticed: when typing in a language with
no dictionary, the word in the middle of the suggestion strip would
always be bold, as if it was going to auto-correct to itself !
This change fixes this bug.
Change-Id: Ia1f08efd7089b9c5cbede910c5b0951d83e698d2
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 9e53cfc3c..398881335 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -223,24 +223,27 @@ public class Suggest { // a boolean flag. Right now this is handled with a slight hack in // WhitelistDictionary#shouldForciblyAutoCorrectFrom. final boolean allowsToBeAutoCorrected = AutoCorrection.isWhitelistedOrNotAWord( - mDictionaries, consideredWord, wordComposer.isFirstCharCapitalized()) - // If we don't have a main dictionary, we never want to auto-correct. The reason for this - // is, the user may have a contact whose name happens to match a valid word in their - // language, and it will unexpectedly auto-correct. For example, if the user types in - // English with no dictionary and has a "Will" in their contact list, "will" would - // always auto-correct to "Will" which is unwanted. Hence, no main dict => no auto-correct. - && hasMainDictionary(); + mDictionaries, consideredWord, wordComposer.isFirstCharCapitalized()); final CharSequence whitelistedWord = mWhiteListDictionary.getWhitelistedWord(consideredWord); final boolean hasAutoCorrection; - if (!isCorrectionEnabled || wordComposer.isMostlyCaps() || wordComposer.isResumed()) { + if (!isCorrectionEnabled || wordComposer.isMostlyCaps() || wordComposer.isResumed() + || !hasMainDictionary()) { + // If we don't have a main dictionary, we never want to auto-correct. The reason for + // this is, the user may have a contact whose name happens to match a valid word in + // their language, and it will unexpectedly auto-correct. For example, if the user + // types in English with no dictionary and has a "Will" in their contact list, "will" + // would always auto-correct to "Will" which is unwanted. Hence, no main dict => no + // auto-correct. hasAutoCorrection = false; } else if (null != whitelistedWord) { hasAutoCorrection = true; - } else if (!AutoCorrection.isWhitelistedOrNotAWord(mDictionaries, consideredWord, - wordComposer.isFirstCharCapitalized())) { + } else if (!allowsToBeAutoCorrected) { + // TODO: make the variable name clearer. If we don't allow auto-correct, that means + // this word is a dictionary word that is not whitelisted, so it should auto-correct + // to itself! Hence, the true here. hasAutoCorrection = true; } else if (suggestionsSet.isEmpty()) { hasAutoCorrection = false; |