From 323196400a5a57a5575875cd6103795d51e19764 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 May 2024 10:39:39 +0700 Subject: [PATCH] fix(android/engine): Ignore updating invalid selections --- .../KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java index bc7dfc5cc6b..68b98240b49 100644 --- a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java +++ b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java @@ -194,10 +194,13 @@ protected boolean updateSelectionRange() { int selMin = icText.selectionStart, selMax = icText.selectionEnd; - if (selMin < 0 || selMax < 0) { + if (selMin < 0 || selMax < 0 || rawText.length() == 0) { // There is no selection or cursor // Reference https://developer.android.com/reference/android/text/Selection#getSelectionEnd(java.lang.CharSequence) return false; + } else if (selMin > rawText.length()-1 || selMax > rawText.length()-1) { + // Selection is past existing text + return false; } if (selMin > selMax) {