aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/RichInputConnection.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-01-09 15:38:39 +0900
committerJean Chalard <jchalard@google.com>2014-01-10 15:21:20 +0900
commit6fbe83be7af6b15df3ed915b408c8179ca01c0cd (patch)
tree81a6200d58e879273b8b5cd19c4aa97985fcd5cc /java/src/com/android/inputmethod/latin/RichInputConnection.java
parent958e4520250e8f2ddcbbbd56afc713262bf1a9f1 (diff)
downloadlatinime-6fbe83be7af6b15df3ed915b408c8179ca01c0cd.tar.gz
latinime-6fbe83be7af6b15df3ed915b408c8179ca01c0cd.tar.xz
latinime-6fbe83be7af6b15df3ed915b408c8179ca01c0cd.zip
[IL53] Fix a wrong test.
This test was intended only for cases without a selection, and as a safety net for cases where the app would pretend the cursor is at N but we can get P chars from the editor where P > N. When there is a selection, this is wrong. In the practice it works because these values are not used in this case, but it's still wrong. The case where P > N is arguable, but actually I see little reason to trust the getTextBeforeCursor() method more than the onUpdate selection method. Plus in the practice, I don't think we are aware of any app with this bug, and it's probably not a great idea to be too robust about this as it may encourage wrong values sent to onUpdateSelection. Change-Id: I42f2065d7aee668074e6b8e40b259da7e88e16e1
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 67ea2991c..d5d2d9c88 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -174,13 +174,15 @@ public final class RichInputConnection {
}
final int lengthOfTextBeforeCursor = mCommittedTextBeforeComposingText.length();
if (lengthOfTextBeforeCursor > newSelStart
- || (lengthOfTextBeforeCursor < Constants.EDITOR_CONTENTS_CACHE_SIZE
+ || (newSelStart != lengthOfTextBeforeCursor
+ && lengthOfTextBeforeCursor < Constants.EDITOR_CONTENTS_CACHE_SIZE
&& newSelStart < Constants.EDITOR_CONTENTS_CACHE_SIZE)) {
// newSelStart and newSelEnd may be lying -- when rotating the device (probably a
- // framework bug). If we have less chars than we asked for, then we know how many chars
- // we have, and if we got more than newSelStart says, then we know it was lying. In both
- // cases the length is more reliable. Note that we only have to check newSelStart (not
- // newSelEnd) since if newSelEnd is wrong, the newSelStart will be wrong as well.
+ // framework bug). If the values don't agree and we have less chars than we asked
+ // for, then we know how many chars we have. If we got more than newSelStart says, then
+ // we also know it was lying. In both cases the length is more reliable. Note that we
+ // only have to check newSelStart (not newSelEnd) since if newSelEnd is wrong, then
+ // newSelStart will be wrong as well.
mExpectedSelStart = lengthOfTextBeforeCursor;
mExpectedSelEnd = lengthOfTextBeforeCursor;
}