abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/ComposeKey.java
diff options
context:
space:
mode:
authorJules Aguillon2025-02-27 22:00:32 +0100
committerJules Aguillon2025-02-27 22:00:32 +0100
commitba05b2770e6a9aa79b9b44ad4a3d0fab8f199bd3 (patch)
treef614970358f0cc58e2a7edadcb7e77ce874124bf /srcs/juloo.keyboard2/ComposeKey.java
parent44d1343b837315c8b3ce5accd5658e6aca1ecdc0 (diff)
downloadunexpected-keyboard-ba05b2770e6a9aa79b9b44ad4a3d0fab8f199bd3.tar.gz
unexpected-keyboard-ba05b2770e6a9aa79b9b44ad4a3d0fab8f199bd3.zip
Fix crash due to empty strings in keys
Diffstat (limited to 'srcs/juloo.keyboard2/ComposeKey.java')
-rw-r--r--srcs/juloo.keyboard2/ComposeKey.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/srcs/juloo.keyboard2/ComposeKey.java b/srcs/juloo.keyboard2/ComposeKey.java
index 57b2a4e..9571c03 100644
--- a/srcs/juloo.keyboard2/ComposeKey.java
+++ b/srcs/juloo.keyboard2/ComposeKey.java
@@ -46,13 +46,15 @@ public final class ComposeKey
matched. */
public static KeyValue apply(int prev, String s)
{
+ final int len = s.length();
int i = 0;
+ if (len == 0) return null;
while (true)
{
KeyValue k = apply(prev, s.charAt(i));
i++;
if (k == null) return null;
- if (i >= s.length()) return k;
+ if (i >= len) return k;
if (k.getKind() != KeyValue.Kind.Compose_pending)
return null; // Found a final state before the end of [s].
prev = k.getPendingCompose();