From 2a81943d162383cc6e9d9429bf3f7949c994a8ba Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 14 Jun 2013 12:25:01 +0900 Subject: [PATCH] Fix a bug with recapitalization This is a shameful bug :/ Bug: 9410367 Change-Id: I54ddbcd0323fa2c11fbd2aa8a1b3d2e07f6e83c8 --- .../com/android/inputmethod/latin/RecapitalizeStatus.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/RecapitalizeStatus.java b/java/src/com/android/inputmethod/latin/RecapitalizeStatus.java index 8a704ab42..b9d7dcf78 100644 --- a/java/src/com/android/inputmethod/latin/RecapitalizeStatus.java +++ b/java/src/com/android/inputmethod/latin/RecapitalizeStatus.java @@ -163,7 +163,10 @@ public class RecapitalizeStatus { final int codePoint = mStringBefore.codePointBefore(nonWhitespaceEnd); if (!Character.isWhitespace(codePoint)) break; } - if (0 != nonWhitespaceStart || len != nonWhitespaceEnd) { + // If nonWhitespaceStart >= nonWhitespaceEnd, that means the selection contained only + // whitespace, so we leave it as is. + if ((0 != nonWhitespaceStart || len != nonWhitespaceEnd) + && nonWhitespaceStart < nonWhitespaceEnd) { mCursorEndAfter = mCursorStartBefore + nonWhitespaceEnd; mCursorStartBefore = mCursorStartAfter = mCursorStartBefore + nonWhitespaceStart; mStringAfter = mStringBefore =