fix(terminal): prevent IME double-fire on mobile input#31
Open
librae8226 wants to merge 1 commit intomasterfrom
Open
fix(terminal): prevent IME double-fire on mobile input#31librae8226 wants to merge 1 commit intomasterfrom
librae8226 wants to merge 1 commit intomasterfrom
Conversation
Three changes to fix duplicated/garbled characters on mobile IMEs (WeChat, Sogou, etc.), especially in English mode: 1. Unified input path: Android now uses our custom <input> element instead of xterm's internal textarea. The textarea leaks IME composition intermediate states on Android, causing a burst of characters on every keystroke. 2. keydownHandledRef guard: When keydown preventsDefault on a printable char, the browser may still update input.value on some mobile engines. The ref marks "already sent" for one event-loop tick, so handleInputChange can skip the duplicate. 3. Strip zero-width characters: Filters U+200B-U+200F, U+FEFF, U+2060-U+206F that leak from some input methods during composition. Co-Authored-By: Claude <noreply@anthropic.com>
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
Fix duplicated/garbled characters on mobile IMEs (WeChat, Sogou, etc.), especially when the keyboard is in English mode.
Changes
Unified input path — Android now uses our custom
<input>element instead of xterm's internal textarea. The textarea leaks IME composition intermediate states on Android, causing a burst of characters on every keystroke.keydownHandledRefguard — WhenkeydowncallspreventDefaulton a printable char, the browser may still updateinput.valueon some mobile engines. The ref marks "already sent" for one event-loop tick, sohandleInputChangecan skip the duplicate.Strip zero-width characters — Filters
U+200B-U+200F,U+FEFF,U+2060-U+206Fthat leak from some input methods during composition.Test plan
Co-Authored-By: Claude noreply@anthropic.com