From f06a553d2c5171de1401e7202af1e86b517794cf Mon Sep 17 00:00:00 2001 From: Helium314 Date: Fri, 13 Jun 2025 20:49:53 +0200 Subject: [PATCH] make sure selection start is before end this should not be necessary according to documentation, but apparently there are apps (even by Google!) that can't deal with documented behavior see comments in GH-1512 --- .../helium314/keyboard/latin/RichInputConnection.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/latin/RichInputConnection.java b/app/src/main/java/helium314/keyboard/latin/RichInputConnection.java index 95beb8683..7d34df49b 100644 --- a/app/src/main/java/helium314/keyboard/latin/RichInputConnection.java +++ b/app/src/main/java/helium314/keyboard/latin/RichInputConnection.java @@ -716,8 +716,13 @@ public final class RichInputConnection implements PrivateCommandPerformer { if (start < 0 || end < 0) { return false; } - mExpectedSelStart = start; - mExpectedSelEnd = end; + if (start > end) { + mExpectedSelStart = end; + mExpectedSelEnd = start; + } else { + mExpectedSelStart = start; + mExpectedSelEnd = end; + } if (isConnected()) { final boolean isIcValid = mIC.setSelection(start, end); if (!isIcValid) {