Repository navigation
fix: spellcheck works in the Android app - #519
Merged
Merged
Conversation
On Android, CodeMirror types through the EditContext API, which bypasses the WebView's spellcheck, so misspellings were never underlined there. The editor now uses the WebView's own editing on Android (EditorView.EDIT_CONTEXT = false). Desktop and web are unaffected; they never used EditContext.
… at a time Without EditContext the browser deletes in the DOM itself, and a drawn marker (a replaced range) goes in one change that CodeMirror reads back as input.type, bypassing the keymap. A transaction filter narrows any backward deletion that removes more than one character of a line's list, task or quote marker prefix, ending at the caret, to the single character before the caret.
Android now types through the WebView's own editing instead of EditContext. The new section says so and lists the kinds of bugs that mode tends to cause, so future work checks for them first.
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.
Description
Makes the EditContext experiment permanent, now that Scott has typed with it for several days without problems.
Spellcheck in the Android app. On Android, CodeMirror types through the EditContext API, which bypasses the WebView's spellcheck, so misspellings were never underlined there (#504 enabled spellcheck, but Android never used it). The editor now uses the WebView's own editing on Android (
EditorView.EDIT_CONTEXT = false, set inproject/src/main.tsbefore the view is created). Scott confirmed on device: underlines and replacement suggestions work. Desktop and web are unaffected; they never used EditContext. Sentence auto-capitalisation doesn't work in either mode, and Scott is fine with that.Backspace safeguard. In this mode the Android keyboard deletes inside the page itself, and CodeMirror tags that as typing (
input.type), not Backspace. So a drawn checkbox, bullet, number or quote marker was removed in one go, breaking the "Backspace deletes one character at a time" rule. Newproject/src/markerBackspaceGuard.tscatches a single deletion that ends at the cursor inside a line's list, task or quote marker, and turns it into a one-character delete. It leaves selections, cut, undo and programmatic changes alone. The one case it can't tell apart: a keyboard "delete word" that lands entirely inside a marker is cut to one character. Heading#markers are left as they are, per Scott.CLAUDE.md gains an "Android text input" section: how input works on Android now, and the kinds of bugs this mode can introduce, to check first when Android typing misbehaves.
Type of Change
On-device testing
Already tested by Scott for several days on the experiment build (branch
experiment/android-without-editcontext, the same two code changes onmain): spellcheck underlines and suggestions work, Backspace into a checkbox deletes one character at a time, and typing has felt normal.How Has This Been Tested?
markerBackspaceGuard.test.ts: 6 of 13 failed before the safeguard, all pass after.listBackspace.e2e.tsgains a DOM-delete step that failed before (got "") and passes after.markdownBackspace.test.ts,enterListIndent,listReveal,undoRedoandtsc -bpassed on the experiment branch.Checklist