diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 323256d1cc6b8031e6fbb0785631e321bbead39b..965518e34aea75483d09129c0877b105f78de902 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -357,9 +357,9 @@ public final class RichInputConnection {
             mExpectedSelEnd -= beforeLength;
         } else {
             // There are fewer characters before the cursor in the buffer than we are being asked to
-            // delete.  Only delete what is there.
-            mExpectedSelStart = 0;
+            // delete. Only delete what is there, and update the end with the amount deleted.
             mExpectedSelEnd -= mExpectedSelStart;
+            mExpectedSelStart = 0;
         }
         if (null != mIC) {
             mIC.deleteSurroundingText(beforeLength, afterLength);