Skip to content

fix(terminal): prevent IME double-fire on mobile input#31

Open
librae8226 wants to merge 1 commit intomasterfrom
fix/ime-double-fire-mobile
Open

fix(terminal): prevent IME double-fire on mobile input#31
librae8226 wants to merge 1 commit intomasterfrom
fix/ime-double-fire-mobile

Conversation

@librae8226
Copy link
Copy Markdown
Owner

Summary

Fix duplicated/garbled characters on mobile IMEs (WeChat, Sogou, etc.), especially when the keyboard is in English mode.

Changes

  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 calls preventDefault 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.

Test plan

  • Android + 微信输入法:逐个按键输入,确认无重复字符
  • iOS + 系统输入法:确认无回归
  • PC 端:确认输入正常

Co-Authored-By: Claude noreply@anthropic.com

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>
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