← 输入框|github.com|刷新
Skip to content

fix(input): resume suggestions on backspace in web editors - #910

Open
saturnspike wants to merge 1 commit into
LeanBitLab:mainfrom
saturnspike:fix/backspace-suggestions
Open

saturnspike wants to merge 1 commit into
LeanBitLab:mainfrom
saturnspike:fix/backspace-suggestions

Conversation

@saturnspike

Copy link
Copy Markdown

Summary of Changes

In web editors (e.g. Gmail compose, browsers), backspacing into the previous word leaves the suggestion strip empty. Tapping the word or using the spacebar to move the cursor into the word correctly displays suggestions. This PR makes a single backspace in web editors resume suggestions in the same way.

Motivation & Context

  1. Make sure "Auto-correction" is on and "Backspace reverts autocorrect" is set to off
  2. Open a web editor text field, e.g. Gmail compose or a text box in Chrome
  3. Type "teh" and press space to trigger an autocorrect to "the"
  4. Press backspace once to delete the space

Expected behavior: the cursor is at the end of "the" and the suggestion strip shows suggestions for "the"
Actual behavior: the suggestion strip stays empty or shows next word predictions

The same steps in a normal text field (e.g. Messages, WhatsApp) show suggestions after backspace. Tapping or using spacebar to move the cursor into the word in Gmail also shows them, so it doesn't seem like this behavior is intentional.

Reproduced on 4.3.5, 4.3.6 and current main (3673402). Couldn't find an existing issue referencing this problem.

Did some debugging and found that the web branch of handleBackspaceEvent always sets the neutral strip, and the selection update caused by the DEL key event is treated as expected and ignored, so nothing resumes the word on backspace.

Changes Made

  • For a single, non-repeat backspace in a web editor, post a delayed resume (postResumeSuggestions(true)) instead of setting the neutral strip.
  • isCursorTouchingWord now reads the text before the cursor from the editor in web editors, since commitText clears the committed text cache there.
  • Added a unit test in InputLogicTest for a single backspace in a web editor. The test harness doesn't clear the cache like a real web editor, so the isCursorTouchingWord part was verified on device only.

Verification & Testing

  • Build compiles cleanly via ./gradlew :app:assembleStandardDebug
  • Tested on device / emulator
  • Verified zero typing latency impact on the input path
  • Checked for regressions across light and dark themes (N/A, no UI changes)

Holding delete still works, and accelerated deletes continue to use the neutral strip so the lag fix from c681284 isn't impacted. Tested the patched build on device against 4.3.6 and holding backspace is just as fast as on 4.3.5 and 4.3.6. Confirmed that "Backspace reverts autocorrect" also still works. InputLogicTest passes (131 tests).

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.

Used Claude Opus 5.5, so not sure if you'll want it. Ensured it is free of em dashes though!

In web editors (e.g. Gmail compose, browsers), backspacing into the previous word leaves the suggestion strip empty. Tapping it or using the spacebar to navigate to the word correctly displays suggestions.

Steps to reproduce
1. Make sure "Auto-correction" is on and "Backspace reverts autocorrect" is set to off
2. Open a web editor text field, e.g. Gmail compose or a text box in Chrome
3. Type "teh" and press space to trigger an autocorrect to "the"
4. Press backspace once to delete the space

Expected behavior: the cursor is at the end of "the" and the suggestion strip shows suggestions for "the"
Actual behavior: the suggestion strip stays empty.

For comparison: the same steps in a normal text field (e.g. Messages, WhatsApp) show suggestions. Tapping or using spacebar to move the cursor into the word in Gmail also shows them, so it doesn't seem intentional.

Reproduced on 4.3.5, 4.3.6 and current main (3673402). Autospace after picking a suggestion is also on, played with immediate auto-space and it didn't seem to make a difference. Did some debugging and found that the web branch of handleBackspaceEvent always sets the neutral strip, and the selection update caused by the DEL key event is treated as expected and ignored.

The fix: for a single, non-repeat backspace, post a delayed resume instead. isCursorTouchingWord now reads the text before the cursor from the editor in web editors, since commitText clears the committed text cache there. Added a unit test for a single backspace in a web editor.

Holding delete still works, and accelerated deletes continue to use the neutral strip so the lag fix from c681284 isn't impacted. Tested the patched build on device against 4.3.6 and holding backspace is just as fast as on 4.3.5 and 4.3.6. Confirmed that "Backspace reverts autocorrect" also still works.
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