Fix a bug where autotext would occasionally not work
Autotext correction would check whether the first suggestion so far was the same as what Autotext would return, and if it was indeed the same, would not send its result as autocorrect. However, the first suggestion is not guaranteed to have a high enough score to trigger autocorrection, and there would be cases where a word in autotext would not get autocorrected because the word came out of bigram suggestions. These occurrences would be extremely rare, as they would require concomitant insert between autotext for one char and bigram suggestion. It is, in fact, probably limited to the capitalization of "I". This did not happen in gingerbread because gingerbread would not register 1-letter words as valid bigrams. This fix works by just always sending the result of autotext regardless of whether it is already the first suggestion or not. This is okay because duplicates are removed afterwards anyway - and this processing is absolutely necessary because the autotext'd word may actually be somewhere else in the suggestion, so it made really no sense checking for only the first one. Please note that there is also a race condition that can result in "i" not being converted to "I": at the moment, Latin IME relies on having the suggestions evaluated at the time autocorrection is performed, but when typing very, very fast, those messages may have been canceled. This is not limited to the autocorrection of "i", but affects all autocorrections. It requires a nearly inhumane typing speed to trigger, but hitting "i" and space in turn as fast as one can it's possible to reproduce occasionally. Bug: 5135113 Change-Id: I530ea6212487300001a2c0fc5b25a5c7716bdf63
This commit is contained in:
parent
b2f93c53db
commit
358e1327d8
1 changed files with 5 additions and 15 deletions
|
@ -371,24 +371,14 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
// Apply quick fix only for the typed word.
|
// Apply quick fix only for the typed word.
|
||||||
if (mQuickFixesEnabled) {
|
if (mQuickFixesEnabled) {
|
||||||
final String lowerCaseTypedWord = typedWordString.toLowerCase();
|
final String lowerCaseTypedWord = typedWordString.toLowerCase();
|
||||||
CharSequence tempAutoText = capitalizeWord(
|
|
||||||
mIsAllUpperCase, mIsFirstCharCapitalized, AutoText.get(
|
|
||||||
lowerCaseTypedWord, 0, lowerCaseTypedWord.length(), view));
|
|
||||||
// TODO: cleanup canAdd
|
|
||||||
// Is there an AutoText (also known as Quick Fixes) correction?
|
// Is there an AutoText (also known as Quick Fixes) correction?
|
||||||
// Capitalize as needed
|
// Capitalize as needed
|
||||||
boolean canAdd = tempAutoText != null;
|
autoText = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized, AutoText.get(
|
||||||
// Is that correction already the current prediction (or original word)?
|
lowerCaseTypedWord, 0, lowerCaseTypedWord.length(), view));
|
||||||
canAdd &= !TextUtils.equals(tempAutoText, typedWord);
|
if (DBG) {
|
||||||
// Is that correction already the next predicted word?
|
if (autoText != null) {
|
||||||
if (canAdd && mSuggestions.size() > 0 && mCorrectionMode != CORRECTION_BASIC) {
|
Log.d(TAG, "Auto corrected by AUTOTEXT: " + typedWord + " -> " + autoText);
|
||||||
canAdd &= !TextUtils.equals(tempAutoText, mSuggestions.get(0));
|
|
||||||
}
|
|
||||||
if (canAdd) {
|
|
||||||
if (DBG) {
|
|
||||||
Log.d(TAG, "Auto corrected by AUTOTEXT.");
|
|
||||||
}
|
}
|
||||||
autoText = tempAutoText;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue