aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/WordComposer.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-03-25 10:46:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-03-25 10:46:32 +0000
commit071b9c1a054bd2bfe3131572de02b30442b01ea3 (patch)
treeb5c35b7afbe8b3d4ad16249ff42821518ed44c67 /java/src/com/android/inputmethod/latin/WordComposer.java
parenteddbb7ac88c3174ffdc38a9dd799029302f55d03 (diff)
parent1079665c3c017ee024a2ffdaf3488cc8c37f087a (diff)
downloadlatinime-071b9c1a054bd2bfe3131572de02b30442b01ea3.tar.gz
latinime-071b9c1a054bd2bfe3131572de02b30442b01ea3.tar.xz
latinime-071b9c1a054bd2bfe3131572de02b30442b01ea3.zip
Merge "[CB14] Implement backspace in the combiner chain"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/WordComposer.java')
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java29
1 files changed, 7 insertions, 22 deletions
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index a60ca3d41..a955f375b 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -314,29 +314,14 @@ public final class WordComposer {
}
/**
- * Delete the last keystroke as a result of hitting backspace.
+ * Delete the last composing unit as a result of hitting backspace.
*/
- public void deleteLast() {
- final int size = size();
- if (size > 0) {
- // Note: mTypedWord.length() and mCodes.length differ when there are surrogate pairs
- final int stringBuilderLength = mTypedWord.length();
- if (stringBuilderLength < size) {
- throw new RuntimeException(
- "In WordComposer: mCodes and mTypedWords have non-matching lengths");
- }
- final int lastChar = mTypedWord.codePointBefore(stringBuilderLength);
- // TODO: with events and composition, this is absolutely not necessarily true.
- mEvents.remove(mEvents.size() - 1);
- if (Character.isSupplementaryCodePoint(lastChar)) {
- mTypedWord.delete(stringBuilderLength - 2, stringBuilderLength);
- } else {
- mTypedWord.deleteCharAt(stringBuilderLength - 1);
- }
- if (Character.isUpperCase(lastChar)) mCapsCount--;
- if (Character.isDigit(lastChar)) mDigitsCount--;
- refreshSize();
- }
+ public void deleteLast(final Event event) {
+ mCombinerChain.processEvent(mEvents, event);
+ mTypedWord.replace(0, mTypedWord.length(),
+ mCombinerChain.getComposingWordWithCombiningFeedback().toString());
+ mEvents.add(event);
+ refreshSize();
// We may have deleted the last one.
if (0 == size()) {
mIsFirstCharCapitalized = false;