Loading java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +9 −1 Original line number Diff line number Diff line Loading @@ -1591,6 +1591,10 @@ public final class InputLogic { final String committedWordString = committedWord.toString(); final int cancelLength = committedWord.length(); final String separatorString = mLastComposedWord.mSeparatorString; // If our separator is a space, we won't actually commit it, // but set the space state to PHANTOM so that a space will be inserted // on the next keypress final boolean usePhantomSpace = separatorString.equals(Constants.STRING_SPACE); // We want java chars, not codepoints for the following. final int separatorLength = separatorString.length(); // TODO: should we check our saved separator against the actual contents of the text view? Loading @@ -1611,7 +1615,8 @@ public final class InputLogic { if (!TextUtils.isEmpty(committedWord)) { mDictionaryFacilitator.removeWordFromPersonalizedDicts(committedWordString); } final String stringToCommit = originallyTypedWord + separatorString; final String stringToCommit = originallyTypedWord + (usePhantomSpace ? "" : separatorString); final SpannableString textToCommit = new SpannableString(stringToCommit); if (committedWord instanceof SpannableString) { final SpannableString committedWordWithSuggestionSpans = (SpannableString)committedWord; Loading Loading @@ -1663,6 +1668,9 @@ public final class InputLogic { } else { mConnection.commitText(textToCommit, 1); } if (usePhantomSpace) { mSpaceState = SpaceState.PHANTOM; } } else { // For languages without spaces, we revert the typed string but the cursor is flush // with the typed word, so we need to resume suggestions right away. Loading tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class BlueUnderlineTests extends InputTestsBase { final int typedLength = STRING_TO_TYPE.length(); final int EXPECTED_SUGGESTION_SPAN_START = -1; final int EXPECTED_UNDERLINE_SPAN_START = 0; final int EXPECTED_UNDERLINE_SPAN_END = 4; final int EXPECTED_UNDERLINE_SPAN_END = 3; type(STRING_TO_TYPE); sleep(DELAY_TO_WAIT_FOR_UNDERLINE); runMessages(); Loading tests/src/com/android/inputmethod/latin/InputLogicTests.java +22 −1 Original line number Diff line number Diff line Loading @@ -159,6 +159,9 @@ public class InputLogicTests extends InputTestsBase { } public void testAutoCorrectWithSpaceThenRevert() { // Backspacing to cancel the "tgis"->"this" autocorrection should result in // a "phantom space": if the user presses space immediately after, // only one space will be inserted in total. final String STRING_TO_TYPE = "tgis "; final String EXPECTED_RESULT = "tgis"; type(STRING_TO_TYPE); Loading @@ -168,6 +171,24 @@ public class InputLogicTests extends InputTestsBase { mEditText.getText().toString()); } public void testAutoCorrectWithSpaceThenRevertThenTypeMore() { final String STRING_TO_TYPE_FIRST = "tgis "; final String STRING_TO_TYPE_SECOND = "a"; final String EXPECTED_RESULT = "tgis a"; type(STRING_TO_TYPE_FIRST); mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE_FIRST.length(), STRING_TO_TYPE_FIRST.length(), -1, -1); type(Constants.CODE_DELETE); type(STRING_TO_TYPE_SECOND); mLatinIME.onUpdateSelection(STRING_TO_TYPE_FIRST.length(), STRING_TO_TYPE_FIRST.length(), STRING_TO_TYPE_FIRST.length() - 1 + STRING_TO_TYPE_SECOND.length(), STRING_TO_TYPE_FIRST.length() - 1 + STRING_TO_TYPE_SECOND.length(), -1, -1); assertEquals("auto-correct with space then revert then type more", EXPECTED_RESULT, mEditText.getText().toString()); } public void testAutoCorrectToSelfDoesNotRevert() { final String STRING_TO_TYPE = "this "; final String EXPECTED_RESULT = "this"; Loading Loading
java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +9 −1 Original line number Diff line number Diff line Loading @@ -1591,6 +1591,10 @@ public final class InputLogic { final String committedWordString = committedWord.toString(); final int cancelLength = committedWord.length(); final String separatorString = mLastComposedWord.mSeparatorString; // If our separator is a space, we won't actually commit it, // but set the space state to PHANTOM so that a space will be inserted // on the next keypress final boolean usePhantomSpace = separatorString.equals(Constants.STRING_SPACE); // We want java chars, not codepoints for the following. final int separatorLength = separatorString.length(); // TODO: should we check our saved separator against the actual contents of the text view? Loading @@ -1611,7 +1615,8 @@ public final class InputLogic { if (!TextUtils.isEmpty(committedWord)) { mDictionaryFacilitator.removeWordFromPersonalizedDicts(committedWordString); } final String stringToCommit = originallyTypedWord + separatorString; final String stringToCommit = originallyTypedWord + (usePhantomSpace ? "" : separatorString); final SpannableString textToCommit = new SpannableString(stringToCommit); if (committedWord instanceof SpannableString) { final SpannableString committedWordWithSuggestionSpans = (SpannableString)committedWord; Loading Loading @@ -1663,6 +1668,9 @@ public final class InputLogic { } else { mConnection.commitText(textToCommit, 1); } if (usePhantomSpace) { mSpaceState = SpaceState.PHANTOM; } } else { // For languages without spaces, we revert the typed string but the cursor is flush // with the typed word, so we need to resume suggestions right away. Loading
tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class BlueUnderlineTests extends InputTestsBase { final int typedLength = STRING_TO_TYPE.length(); final int EXPECTED_SUGGESTION_SPAN_START = -1; final int EXPECTED_UNDERLINE_SPAN_START = 0; final int EXPECTED_UNDERLINE_SPAN_END = 4; final int EXPECTED_UNDERLINE_SPAN_END = 3; type(STRING_TO_TYPE); sleep(DELAY_TO_WAIT_FOR_UNDERLINE); runMessages(); Loading
tests/src/com/android/inputmethod/latin/InputLogicTests.java +22 −1 Original line number Diff line number Diff line Loading @@ -159,6 +159,9 @@ public class InputLogicTests extends InputTestsBase { } public void testAutoCorrectWithSpaceThenRevert() { // Backspacing to cancel the "tgis"->"this" autocorrection should result in // a "phantom space": if the user presses space immediately after, // only one space will be inserted in total. final String STRING_TO_TYPE = "tgis "; final String EXPECTED_RESULT = "tgis"; type(STRING_TO_TYPE); Loading @@ -168,6 +171,24 @@ public class InputLogicTests extends InputTestsBase { mEditText.getText().toString()); } public void testAutoCorrectWithSpaceThenRevertThenTypeMore() { final String STRING_TO_TYPE_FIRST = "tgis "; final String STRING_TO_TYPE_SECOND = "a"; final String EXPECTED_RESULT = "tgis a"; type(STRING_TO_TYPE_FIRST); mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE_FIRST.length(), STRING_TO_TYPE_FIRST.length(), -1, -1); type(Constants.CODE_DELETE); type(STRING_TO_TYPE_SECOND); mLatinIME.onUpdateSelection(STRING_TO_TYPE_FIRST.length(), STRING_TO_TYPE_FIRST.length(), STRING_TO_TYPE_FIRST.length() - 1 + STRING_TO_TYPE_SECOND.length(), STRING_TO_TYPE_FIRST.length() - 1 + STRING_TO_TYPE_SECOND.length(), -1, -1); assertEquals("auto-correct with space then revert then type more", EXPECTED_RESULT, mEditText.getText().toString()); } public void testAutoCorrectToSelfDoesNotRevert() { final String STRING_TO_TYPE = "this "; final String EXPECTED_RESULT = "this"; Loading