Skip to content

fix(swipe): delete composing word on full keyboard swipe - #878

Open
zoickx wants to merge 2 commits into
LeanBitLab:mainfrom
zoickx:fix/swipe-delete-composing-word
Open

zoickx wants to merge 2 commits into
LeanBitLab:mainfrom
zoickx:fix/swipe-delete-composing-word

Conversation

@zoickx

@zoickx zoickx commented Nov 19, 2026

Copy link
Copy Markdown

Summary of Changes

With Full keyboard swipe gesture set to Delete word, swiping left while a word is still being typed (underlined) did not delete it. The word was only finalized, and a second swipe was needed. This PR makes the first swipe delete it.

Motivation & Context

No issue filed for this. The gesture was added for #757.

Steps to reproduce on current main:

  1. Set Gesture typing > Full keyboard swipe gesture to Delete word.
  2. Type hello wor and do not press space.
  3. Swipe left across the keyboard.

Expected: wor is deleted.
Actual: wor stays and loses its underline. A second swipe deletes it.

Side effects of the same bug:

  • The suggestion strip switches to next-word predictions, and a picked one is appended without a space.
  • The word is unlearned from user history although it stays in the text.

Root cause: in the composing branch of InputLogic.deleteWordBeforeCursor(), finishComposingText() ran before commitText("", 1). After the finish there is no composing span left, so the empty commit replaced nothing, and the branch returned early.

Changes Made

  • The composing branch now only finalizes the word and resets the composing state, then falls through to the regular deletion below. This is how handleBackspaceRepeatWordDeletion() already treats a composing word.
  • 4 lines removed in InputLogic.kt, nothing added.
  • With the cursor inside a composing word, only the part before the cursor is deleted, as with hold-backspace word deletion and the delete key swipe.
  • Two tests in InputLogicTest for a composing word: cursor at its end, and cursor inside it.

Verification & Testing

  • Build compiles cleanly via ./gradlew :app:assembleStandardDebug
    (built with ./gradlew assembleDebug, standard and offline, on GitHub Actions in my fork: https://github.com/zoickx/LeanType/actions/runs/44590999769, no warnings in InputLogic.kt)
  • Tested on device / emulator
    (debug APK from that build on LineageOS 23.2 (Android 16): composing word, cursor inside a word, word followed by a space)
  • Verified zero typing latency impact on the input path
    (the change only removes calls, and the code runs only on the swipe gesture)
  • Checked for regressions across light and dark themes
    (not applicable, no UI change)
  • ./gradlew :app:testStandardRunTestsUnitTest --tests 'helium314.keyboard.latin.InputLogicTest': 130 tests, 0 failed, 1 skipped. Without the fix the two new tests fail. Run on my fork: https://github.com/zoickx/LeanType/actions/runs/44598065997

Guidelines Checklist

  • This PR addresses a single focused concern.
  • Follows coding guidelines in CONTRIBUTING.md.
  • Does not add unnecessary dependencies or binary blobs.
  • No em dashes used in comments, descriptions, or documentation.

Note, out of scope

There are three separate implementations of "delete the word before the cursor": this gesture, hold-backspace word deletion, and the delete key swipe with Delete word by word. The first two share getStartOfPreviousWord() and keep the space before the word. The delete key swipe uses getWordBoundariesBackwards() and removes that space too. This PR does not change any of that. I only mention it in case the difference is not intended.

- "Delete word" swipe finalized the word being typed, deleted nothing
- Cause: finishComposingText() before commitText(""), so the empty
  commit had no composing span to replace
- Now: finalize, then fall through to the regular deletion, same as
  hold-backspace word deletion
- Composing word at the cursor is deleted by one swipe
- Cursor inside a composing word: only the part before it is deleted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant