Don't autocorrect after suggestion resuming
Bug: 6105732
Change-Id: I92e7a9c6d6eb648f747c3b396d7993479fd8478a
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 7cbee4f..112bde6 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -385,6 +385,7 @@
}
// Don't auto-correct words with multiple capital letter
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
+ autoCorrectionAvailable &= !wordComposer.isResumed();
if (allowsToBeAutoCorrected && suggestionsList.size() > 1 && mAutoCorrectionThreshold > 0
&& Suggest.shouldBlockAutoCorrectionBySafetyNet(typedWord,
suggestionsList.get(1).mWord)) {
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index bd8532e..e27a546 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -38,6 +38,7 @@
private int[] mYCoordinates;
private StringBuilder mTypedWord;
private CharSequence mAutoCorrection;
+ private boolean mIsResumed;
// Cache these values for performance
private int mCapsCount;
@@ -57,6 +58,7 @@
mYCoordinates = new int[N];
mAutoCorrection = null;
mTrailingSingleQuotesCount = 0;
+ mIsResumed = false;
refreshSize();
}
@@ -73,6 +75,7 @@
mIsFirstCharCapitalized = source.mIsFirstCharCapitalized;
mAutoCapitalized = source.mAutoCapitalized;
mTrailingSingleQuotesCount = source.mTrailingSingleQuotesCount;
+ mIsResumed = source.mIsResumed;
refreshSize();
}
@@ -85,6 +88,7 @@
mCapsCount = 0;
mIsFirstCharCapitalized = false;
mTrailingSingleQuotesCount = 0;
+ mIsResumed = false;
refreshSize();
}
@@ -193,6 +197,7 @@
int codePoint = Character.codePointAt(word, i);
addKeyInfo(codePoint, keyboard);
}
+ mIsResumed = true;
}
/**
@@ -299,6 +304,13 @@
return mAutoCorrection;
}
+ /**
+ * @return whether we started composing this word by resuming suggestion on an existing string
+ */
+ public boolean isResumed() {
+ return mIsResumed;
+ }
+
// `type' should be one of the LastComposedWord.COMMIT_TYPE_* constants above.
public LastComposedWord commitWord(final int type, final String committedWord,
final int separatorCode) {
@@ -320,6 +332,7 @@
mTypedWord.setLength(0);
refreshSize();
mAutoCorrection = null;
+ mIsResumed = false;
return lastComposedWord;
}
@@ -331,5 +344,6 @@
mTypedWord.append(lastComposedWord.mTypedWord);
refreshSize();
mAutoCorrection = null; // This will be filled by the next call to updateSuggestion.
+ mIsResumed = true;
}
}