Merge "Use the stored separator instead of reading it back (A3)"
commit
8db74d0fae
|
@ -76,4 +76,12 @@ public class LastComposedWord {
|
||||||
return mActive && !TextUtils.isEmpty(mCommittedWord)
|
return mActive && !TextUtils.isEmpty(mCommittedWord)
|
||||||
&& !TextUtils.equals(mTypedWord, mCommittedWord);
|
&& !TextUtils.equals(mTypedWord, mCommittedWord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean didCommitTypedWord() {
|
||||||
|
return TextUtils.equals(mTypedWord, mCommittedWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getSeparatorLength(final int separatorCode) {
|
||||||
|
return NOT_A_SEPARATOR == separatorCode ? 0 : 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2174,14 +2174,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
final String originallyTypedWord = mLastComposedWord.mTypedWord;
|
final String originallyTypedWord = mLastComposedWord.mTypedWord;
|
||||||
final CharSequence committedWord = mLastComposedWord.mCommittedWord;
|
final CharSequence committedWord = mLastComposedWord.mCommittedWord;
|
||||||
final int cancelLength = committedWord.length();
|
final int cancelLength = committedWord.length();
|
||||||
final CharSequence separator = ic.getTextBeforeCursor(1, 0);
|
final int separatorLength = mLastComposedWord.getSeparatorLength(
|
||||||
|
mLastComposedWord.mSeparatorCode);
|
||||||
|
// TODO: should we check our saved separator against the actual contents of the text view?
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
if (mWordComposer.isComposingWord()) {
|
if (mWordComposer.isComposingWord()) {
|
||||||
throw new RuntimeException("cancelAutoCorrect, but we are composing a word");
|
throw new RuntimeException("cancelAutoCorrect, but we are composing a word");
|
||||||
}
|
}
|
||||||
final String wordBeforeCursor =
|
final String wordBeforeCursor =
|
||||||
ic.getTextBeforeCursor(cancelLength + 1, 0).subSequence(0, cancelLength)
|
ic.getTextBeforeCursor(cancelLength + separatorLength, 0)
|
||||||
.toString();
|
.subSequence(0, cancelLength).toString();
|
||||||
if (!TextUtils.equals(committedWord, wordBeforeCursor)) {
|
if (!TextUtils.equals(committedWord, wordBeforeCursor)) {
|
||||||
throw new RuntimeException("cancelAutoCorrect check failed: we thought we were "
|
throw new RuntimeException("cancelAutoCorrect check failed: we thought we were "
|
||||||
+ "reverting \"" + committedWord
|
+ "reverting \"" + committedWord
|
||||||
|
@ -2193,13 +2195,21 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
+ "\" but we found this very string before the cursor");
|
+ "\" but we found this very string before the cursor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ic.deleteSurroundingText(cancelLength + 1, 0);
|
ic.deleteSurroundingText(cancelLength + separatorLength, 0);
|
||||||
ic.commitText(originallyTypedWord, 1);
|
if (0 == separatorLength || mLastComposedWord.didCommitTypedWord()) {
|
||||||
// Re-insert the separator
|
// This is the case when we cancel a manual pick.
|
||||||
ic.commitText(separator, 1);
|
// TODO: implement this
|
||||||
|
// We should restart suggestion on the word right away.
|
||||||
|
} else {
|
||||||
|
ic.commitText(originallyTypedWord, 1);
|
||||||
|
// Re-insert the separator
|
||||||
|
sendKeyCodePoint(mLastComposedWord.mSeparatorCode);
|
||||||
|
Utils.Stats.onSeparator(mLastComposedWord.mSeparatorCode, WordComposer.NOT_A_COORDINATE,
|
||||||
|
WordComposer.NOT_A_COORDINATE);
|
||||||
|
// Don't restart suggestion yet. We'll restart if the user deletes the
|
||||||
|
// separator.
|
||||||
|
}
|
||||||
mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
|
mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
|
||||||
Utils.Stats.onSeparator(separator.charAt(0), WordComposer.NOT_A_COORDINATE,
|
|
||||||
WordComposer.NOT_A_COORDINATE);
|
|
||||||
mHandler.cancelUpdateBigramPredictions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue