diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index c35c96016..3d32ee6b7 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -2059,10 +2059,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (ic == null) return false; CharSequence before = ic.getTextBeforeCursor(1, 0); CharSequence after = ic.getTextAfterCursor(1, 0); - if (!TextUtils.isEmpty(before) && !mSettingsValues.isWordSeparator(before.charAt(0))) { + if (!TextUtils.isEmpty(before) && !mSettingsValues.isWordSeparator(before.charAt(0)) + && !mSettingsValues.isSymbolExcludedFromWordSeparators(before.charAt(0))) { return true; } - if (!TextUtils.isEmpty(after) && !mSettingsValues.isWordSeparator(after.charAt(0))) { + if (!TextUtils.isEmpty(after) && !mSettingsValues.isWordSeparator(after.charAt(0)) + && !mSettingsValues.isSymbolExcludedFromWordSeparators(after.charAt(0))) { return true; } return false; diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index a6a4d9343..595fe5b10 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -554,6 +554,22 @@ public class InputLogicTests extends ServiceTestCase { EXPECTED_RESULT, mTextView.getText().toString()); } + public void testAutoCorrectionWithSingleQuoteInside() { + final String WORD_TO_TYPE = "you'f "; + final String EXPECTED_RESULT = "you'd "; + type(WORD_TO_TYPE); + assertEquals("auto-correction with single quote inside", + EXPECTED_RESULT, mTextView.getText().toString()); + } + + public void testAutoCorrectionWithSingleQuotesAround() { + final String WORD_TO_TYPE = "'tgis' "; + final String EXPECTED_RESULT = "'this' "; + type(WORD_TO_TYPE); + assertEquals("auto-correction with single quotes around", + EXPECTED_RESULT, mTextView.getText().toString()); + } + // A helper class to ease span tests private static class Span { final SpannableStringBuilder mInputText;