diff --git a/app/src/main/java/helium314/keyboard/latin/Suggest.kt b/app/src/main/java/helium314/keyboard/latin/Suggest.kt index cac9f9058..5e460ac34 100644 --- a/app/src/main/java/helium314/keyboard/latin/Suggest.kt +++ b/app/src/main/java/helium314/keyboard/latin/Suggest.kt @@ -308,6 +308,9 @@ class Suggest(private val mDictionaryFacilitator: DictionaryFacilitator) { || (wordComposer.isMostlyCaps() && !wordComposer.isAllUpperCase()) // We never auto-correct when suggestions are resumed because it would be unexpected || wordComposer.isResumed() // If we don't have a main dictionary, we never want to auto-correct. The reason || isDeveloperTokenOrSpecialSyntax(consideredWord) + // never replace a typed word with an emoji, unless the user mapped it as a shortcut. The emoji dictionary + // is part of the main dictionary, so without a word list emojis can be the only candidates + || (firstSuggestionInContainer?.isEmoji == true && !isExactShortcut(firstSuggestionInContainer)) // 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 diff --git a/app/src/test/java/helium314/keyboard/latin/SuggestTest.kt b/app/src/test/java/helium314/keyboard/latin/SuggestTest.kt index 45e3d4736..3f684a400 100644 --- a/app/src/test/java/helium314/keyboard/latin/SuggestTest.kt +++ b/app/src/test/java/helium314/keyboard/latin/SuggestTest.kt @@ -52,6 +52,20 @@ class SuggestTest { .edit { putBoolean(Settings.PREF_AUTO_CORRECTION, true) } // need to enable, off by default } + // with only an emoji dictionary (no word list), emojis are the only candidates for any unknown word + @Test fun `unknown word is not autocorrected to an emoji`() { + val locale = Locale.ENGLISH + val result = shouldBeAutoCorrected( + "lov", + listOf(suggestion("\uD83D\uDE0D", Int.MAX_VALUE, locale)), + null, + null, + locale, + thresholdVeryAggressive + ) + assert(!result.last()) // should not be corrected + } + @Test fun `'on' to 'in' if 'in' was used before in this context`() { val locale = Locale.ENGLISH val result = shouldBeAutoCorrected(