diff --git a/common/src/org/futo/inputmethod/latin/common/StringUtils.java b/common/src/org/futo/inputmethod/latin/common/StringUtils.java index 659e1862c..42401c581 100644 --- a/common/src/org/futo/inputmethod/latin/common/StringUtils.java +++ b/common/src/org/futo/inputmethod/latin/common/StringUtils.java @@ -448,6 +448,10 @@ public final class StringUtils { int codePoint = 0; while (i > 0) { codePoint = Character.codePointBefore(text, i); + if (Constants.CODE_COMMERCIAL_AT == codePoint) { + // If it's an email address, it's essentially a URL, we don't want to correct those + return true; + } if (codePoint < Constants.CODE_PERIOD || codePoint > 'z') { // Handwavy heuristic to see if that's a URL character. Anything between period // and z. This includes all lower- and upper-case ascii letters, period, diff --git a/java/src/org/futo/inputmethod/latin/Suggest.java b/java/src/org/futo/inputmethod/latin/Suggest.java index cea260c29..13c6f71c6 100644 --- a/java/src/org/futo/inputmethod/latin/Suggest.java +++ b/java/src/org/futo/inputmethod/latin/Suggest.java @@ -222,7 +222,9 @@ public final class Suggest { // If the first suggestion is a shortcut we never auto-correct to it, regardless // of how strong it is (allowlist entries are not KIND_SHORTCUT but KIND_WHITELIST). // TODO: we may want to have shortcut-only entries auto-correct in the future. - || suggestionResults.first().isKindOf(SuggestedWordInfo.KIND_SHORTCUT)) { + || suggestionResults.first().isKindOf(SuggestedWordInfo.KIND_SHORTCUT) + // Don't do it if it looks like a URL (or email address) + || StringUtils.lastPartLooksLikeURL(typedWordString)) { hasAutoCorrection = false; } else { final SuggestedWordInfo firstSuggestion = suggestionResults.first(); diff --git a/java/src/org/futo/inputmethod/latin/SuggestedWords.java b/java/src/org/futo/inputmethod/latin/SuggestedWords.java index c02b421d2..2ed27fadf 100644 --- a/java/src/org/futo/inputmethod/latin/SuggestedWords.java +++ b/java/src/org/futo/inputmethod/latin/SuggestedWords.java @@ -60,7 +60,7 @@ public class SuggestedWords { // Note: this INCLUDES cases where the word will auto-correct to itself. A good definition // of what this flag means would be "the top suggestion is strong enough to auto-correct", // whether this exactly matches the user entry or not. - public final boolean mWillAutoCorrect; + public boolean mWillAutoCorrect; public final boolean mIsObsoleteSuggestions; // How the input for these suggested words was done by the user. Must be one of the // INPUT_STYLE_* constants above. diff --git a/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java b/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java index ab7d9c70c..ded932fa3 100644 --- a/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/org/futo/inputmethod/latin/inputlogic/InputLogic.java @@ -585,6 +585,8 @@ public final class InputLogic { // Especially, how do we deal with InputMethodService.onDisplayCompletions? public void setSuggestedWords(final SuggestedWords suggestedWords) { if (!suggestedWords.isEmpty()) { + suggestedWords.mWillAutoCorrect = suggestedWords.mWillAutoCorrect + && !mConnection.textBeforeCursorLooksLikeURL(); final SuggestedWordInfo suggestedWordInfo; if (suggestedWords.mWillAutoCorrect) { suggestedWordInfo = suggestedWords.getInfo(SuggestedWords.INDEX_OF_AUTO_CORRECTION);