aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTom Ouyang <ouyang@google.com>2015-04-02 01:42:11 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-02 01:42:11 +0000
commitfca41b7d8bab2f643f013a080944ad8ae19b97f2 (patch)
tree1a087eb7c2763beeb9f9cfcda5ac9c71b00abe80 /java
parent5c1e8edf37e8ada8ecc6701e196c22a777952170 (diff)
parent1a58c47ebe137ee1d5b3a2567b97802946945d38 (diff)
downloadlatinime-fca41b7d8bab2f643f013a080944ad8ae19b97f2.tar.gz
latinime-fca41b7d8bab2f643f013a080944ad8ae19b97f2.tar.xz
latinime-fca41b7d8bab2f643f013a080944ad8ae19b97f2.zip
am 1a58c47e: Unlearn word when the user moves the cursor in to correct it.
* commit '1a58c47ebe137ee1d5b3a2567b97802946945d38': Unlearn word when the user moves the cursor in to correct it.
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 5b3b28d75..cf4064b72 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -476,6 +476,9 @@ public final class InputLogic {
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection
// first so that we can insert the batch input at the current cursor position.
+ // We also need to unlearn the original word that is now being corrected.
+ unlearnWord(mWordComposer.getTypedWord(), settingsValues,
+ Constants.EVENT_BACKSPACE);
resetEntireInputState(mConnection.getExpectedSelectionStart(),
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
} else if (mWordComposer.isSingleLetter()) {
@@ -742,6 +745,9 @@ public final class InputLogic {
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection
// first so that we can insert the character at the current cursor position.
+ // We also need to unlearn the original word that is now being corrected.
+ unlearnWord(mWordComposer.getTypedWord(), inputTransaction.mSettingsValues,
+ Constants.EVENT_BACKSPACE);
resetEntireInputState(mConnection.getExpectedSelectionStart(),
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
} else {
@@ -781,6 +787,9 @@ public final class InputLogic {
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection
// first so that we can insert the character at the current cursor position.
+ // We also need to unlearn the original word that is now being corrected.
+ unlearnWord(mWordComposer.getTypedWord(), inputTransaction.mSettingsValues,
+ Constants.EVENT_BACKSPACE);
resetEntireInputState(mConnection.getExpectedSelectionStart(),
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
isComposingWord = false;
@@ -847,6 +856,9 @@ public final class InputLogic {
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection
// first so that we can insert the separator at the current cursor position.
+ // We also need to unlearn the original word that is now being corrected.
+ unlearnWord(mWordComposer.getTypedWord(), inputTransaction.mSettingsValues,
+ Constants.EVENT_BACKSPACE);
resetEntireInputState(mConnection.getExpectedSelectionStart(),
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
}
@@ -962,6 +974,9 @@ public final class InputLogic {
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection
// first so that we can remove the character at the current cursor position.
+ // We also need to unlearn the original word that is now being corrected.
+ unlearnWord(mWordComposer.getTypedWord(), inputTransaction.mSettingsValues,
+ Constants.EVENT_BACKSPACE);
resetEntireInputState(mConnection.getExpectedSelectionStart(),
mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */);
// When we exit this if-clause, mWordComposer.isComposingWord() will return false.
@@ -1046,6 +1061,10 @@ public final class InputLogic {
// We should backspace one char and restart suggestion if at the end of a word.
if (mConnection.hasSelection()) {
// If there is a selection, remove it.
+ // We also need to unlearn the selected text.
+ final CharSequence selection = mConnection.getSelectedText(0 /* 0 for no styles */);
+ unlearnWord(selection.toString(), inputTransaction.mSettingsValues,
+ Constants.EVENT_BACKSPACE);
final int numCharsDeleted = mConnection.getExpectedSelectionEnd()
- mConnection.getExpectedSelectionStart();
mConnection.setSelection(mConnection.getExpectedSelectionEnd(),