From 2188a2b03a84001654f61e6bde886fa823ac7c88 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Thu, 11 Jan 2024 15:19:09 +0200 Subject: [PATCH] Make digits and letters same class --- .../futo/inputmethod/latin/RichInputConnection.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/java/src/org/futo/inputmethod/latin/RichInputConnection.java b/java/src/org/futo/inputmethod/latin/RichInputConnection.java index 2db66cf0b..b8dfba59e 100644 --- a/java/src/org/futo/inputmethod/latin/RichInputConnection.java +++ b/java/src/org/futo/inputmethod/latin/RichInputConnection.java @@ -1083,10 +1083,9 @@ public final class RichInputConnection implements PrivateCommandPerformer { } private int getCharacterClass(char c) { - if(Character.isLetter(c) || c == '_') return 1; - else if(Character.isDigit(c)) return 2; - else if(Character.isWhitespace(c)) return 3; - else return 4; + if(Character.isLetter(c) || c == '_' || Character.isDigit(c)) return 1; + else if(Character.isWhitespace(c)) return 2; + else return 3; } /** @@ -1112,7 +1111,7 @@ public final class RichInputConnection implements PrivateCommandPerformer { } // Find the last word boundary - int charClass = getCharacterClass(charsBeforeCursor.charAt(i)); + int charClass = i >= 0 ? getCharacterClass(charsBeforeCursor.charAt(i)) : -1; while (i >= 0 && getCharacterClass(charsBeforeCursor.charAt(i)) == charClass) { i--; steps--; @@ -1140,7 +1139,7 @@ public final class RichInputConnection implements PrivateCommandPerformer { } // Find the first word boundary - int charClass = getCharacterClass(charsAfterCursor.charAt(i)); + int charClass = i < charsAfterCursor.length() ? getCharacterClass(charsAfterCursor.charAt(i)) : -1; while (i < charsAfterCursor.length() && getCharacterClass(charsAfterCursor.charAt(i)) == charClass) { i++; steps++;