diff options
author | 2012-02-21 23:11:07 -0800 | |
---|---|---|
committer | 2012-02-21 23:12:21 -0800 | |
commit | cf9d92629cae88273805eaf7984fcfdd8afd11f5 (patch) | |
tree | 0e42974e0a16159e64ef5ae51af36656a43415ee /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | c6993e4947d0d2c5ac673fbaa99c816b69043074 (diff) | |
download | latinime-cf9d92629cae88273805eaf7984fcfdd8afd11f5.tar.gz latinime-cf9d92629cae88273805eaf7984fcfdd8afd11f5.tar.xz latinime-cf9d92629cae88273805eaf7984fcfdd8afd11f5.zip |
Give LastComposedWord knowledge of the committed word (A1)
There is no point storing the prospective autocorrect - we are
recomputing it anyway. The committed word however will be necessary
to implement feature request #5968922.
Change-Id: I588c18e1a5a1050a791d601de465f421ccbe36cd
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index da268451b..a40bcdfe2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1129,8 +1129,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public void commitTyped(final InputConnection ic) { if (!mWordComposer.isComposingWord()) return; final CharSequence typedWord = mWordComposer.getTypedWord(); - mLastComposedWord = mWordComposer.commitWord(LastComposedWord.COMMIT_TYPE_USER_TYPED_WORD); if (typedWord.length() > 0) { + mLastComposedWord = mWordComposer.commitWord( + LastComposedWord.COMMIT_TYPE_USER_TYPED_WORD, typedWord.toString()); if (ic != null) { ic.commitText(typedWord, 1); } @@ -2034,7 +2035,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // what user typed. Note: currently this is done much later in // LastComposedWord#canCancelAutoCorrect by string equality of the remembered // strings. - mLastComposedWord = mWordComposer.commitWord(commitType); + mLastComposedWord = mWordComposer.commitWord(commitType, bestWord.toString()); } private static final WordComposer sEmptyWordComposer = new WordComposer(); @@ -2198,8 +2199,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // "ic" must not be null private void cancelAutoCorrect(final InputConnection ic) { final String originallyTypedWord = mLastComposedWord.mTypedWord; - final CharSequence autoCorrectedTo = mLastComposedWord.mAutoCorrection; - final int cancelLength = autoCorrectedTo.length(); + final CharSequence committedWord = mLastComposedWord.mCommittedWord; + final int cancelLength = committedWord.length(); final CharSequence separator = ic.getTextBeforeCursor(1, 0); if (DEBUG) { if (mWordComposer.isComposingWord()) { @@ -2208,9 +2209,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final String wordBeforeCursor = ic.getTextBeforeCursor(cancelLength + 1, 0).subSequence(0, cancelLength) .toString(); - if (!TextUtils.equals(autoCorrectedTo, wordBeforeCursor)) { + if (!TextUtils.equals(committedWord, wordBeforeCursor)) { throw new RuntimeException("cancelAutoCorrect check failed: we thought we were " - + "reverting \"" + autoCorrectedTo + + "reverting \"" + committedWord + "\", but before the cursor we found \"" + wordBeforeCursor + "\""); } if (TextUtils.equals(originallyTypedWord, wordBeforeCursor)) { |