am 825e2bbd: Fix a bug when deleting the last char

* commit '825e2bbd910cce3055a4ca808d3744bc0b2cedda':
  Fix a bug when deleting the last char
This commit is contained in:
Jean Chalard 2012-02-02 20:09:39 -08:00 committed by Android Git Automerger
commit 7876326bf1
2 changed files with 13 additions and 2 deletions

View file

@ -212,6 +212,7 @@ public class WordComposer {
final int lastPos = size - 1;
char lastChar = mTypedWord.charAt(lastPos);
mCodes.remove(lastPos);
// TODO: This crashes and catches fire if the code point doesn't fit a char
mTypedWord.deleteCharAt(lastPos);
if (Character.isUpperCase(lastChar)) mCapsCount--;
}
@ -221,8 +222,9 @@ public class WordComposer {
if (mTrailingSingleQuotesCount > 0) {
--mTrailingSingleQuotesCount;
} else {
for (int i = mTypedWord.offsetByCodePoints(mTypedWord.length(), -1);
i >= 0; i = mTypedWord.offsetByCodePoints(i, -1)) {
int i = mTypedWord.length();
while (i > 0) {
i = mTypedWord.offsetByCodePoints(i, -1);
if (Keyboard.CODE_SINGLE_QUOTE != mTypedWord.codePointAt(i)) break;
++mTrailingSingleQuotesCount;
}

View file

@ -291,4 +291,13 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
assertEquals("manual pick then space then type", WORD1_TO_TYPE + WORD2_TO_TYPE,
mTextView.getText().toString());
}
public void testDeleteWholeComposingWord() {
final String WORD_TO_TYPE = "this";
type(WORD_TO_TYPE);
for (int i = 0; i < WORD_TO_TYPE.length(); ++i) {
type(Keyboard.CODE_DELETE);
}
assertEquals("delete whole composing word", "", mTextView.getText().toString());
}
}