From f2a46cfa9a84c32660e12e6db007822aae8737db Mon Sep 17 00:00:00 2001 From: Helium314 Date: Mon, 3 Feb 2025 00:20:48 +0100 Subject: [PATCH] disable undo-like functionality for textInput, fixes #1019 --- .../keyboard/latin/inputlogic/InputLogic.java | 7 ++++- .../keyboard/latin/InputLogicTest.kt | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java index ff782ebd8..a2f4fdb38 100644 --- a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java +++ b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java @@ -1212,7 +1212,12 @@ public final class InputLogic { } return; } - if (mEnteredText != null && mConnection.sameAsTextBeforeCursor(mEnteredText)) { + // todo: this is currently disabled, as it causes inconsistencies with textInput, depending whether the end + // is part of a word (where we start composing) or not (where we end in code below) + // see https://github.com/Helium314/HeliBoard/issues/1019 + // with better emoji detection on backspace (getFullEmojiAtEnd), this functionality might not be necessary + // -> enable again if there are issues, otherwise delete the code, together with mEnteredText + if (false && mEnteredText != null && mConnection.sameAsTextBeforeCursor(mEnteredText)) { // Cancel multi-character input: remove the text we just entered. // This is triggered on backspace after a key that inputs multiple characters, // like the smiley key or the .com key. diff --git a/app/src/test/java/helium314/keyboard/latin/InputLogicTest.kt b/app/src/test/java/helium314/keyboard/latin/InputLogicTest.kt index 08cf13fdc..41cf69de5 100644 --- a/app/src/test/java/helium314/keyboard/latin/InputLogicTest.kt +++ b/app/src/test/java/helium314/keyboard/latin/InputLogicTest.kt @@ -613,6 +613,35 @@ class InputLogicTest { assertEquals("{\"label\": \"c", text) } + @Test fun `text input and delete`() { + reset() + input("hello") + assertEquals("hello", text) + functionalKeyPress(KeyCode.DELETE) + assertEquals("hell", text) + + reset() + input("hello ") + assertEquals("hello ", text) + functionalKeyPress(KeyCode.DELETE) + assertEquals("hello", text) + } + + @Test fun `emoji text input and delete`() { + reset() + input("🕵🏼") + functionalKeyPress(KeyCode.DELETE) + assertEquals("", text) + + reset() + input("\uD83D\uDD75\uD83C\uDFFC") + input(' ') + assertEquals("🕵🏼 ", text) + functionalKeyPress(KeyCode.DELETE) + functionalKeyPress(KeyCode.DELETE) + assertEquals("", text) + } + // ------- helper functions --------- // should be called before every test, so the same state is guaranteed