Repository navigation
fix(input): resume suggestions on backspace in web editors - #910
Open
saturnspike wants to merge 1 commit into
Open
saturnspike wants to merge 1 commit into
saturnspike wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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
postResumeSuggestions(true)) instead of setting the neutral strip.isCursorTouchingWordnow reads the text before the cursor from the editor in web editors, since commitText clears the committed text cache there.isCursorTouchingWordpart was verified on device only.Verification & Testing
./gradlew :app:assembleStandardDebugHolding 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
Used Claude Opus 5.5, so not sure if you'll want it. Ensured it is free of em dashes though!