Skip to content

fix(terminal): preserve IME punctuation input - #327

Merged
Ark0N merged 1 commit into
Ark0N:masterfrom
dignfei:fix/terminal-ime-punctuation
Aug 21, 2026
Merged

fix(terminal): preserve IME punctuation input#327
Ark0N merged 1 commit into
Ark0N:masterfrom
dignfei:fix/terminal-ime-punctuation

Conversation

@dignfei

Copy link
Copy Markdown

Summary

  • delegate active-IME Process/keyCode 229 events to xterm's native CompositionHelper
  • remove the redundant Android orphan-input fallback so xterm remains the single input owner
  • send the browser's committed input text from the explicit CJK field instead of guessing from KeyboardEvent.key
  • cover the complete full-width punctuation sequence on desktop and touch-capable Chromium

Root cause

Codeman's custom xterm key handler returned false for keyCode 229 before xterm could run its CompositionHelper. Active Chinese IMEs use a non-composing 229 event when committing numbers and punctuation, so the subsequent textarea change never reached terminal onData. The separate CJK input field also prevented the printable keydown and sent its physical ASCII key before the IME could transform it.

The fix delegates these events to xterm and treats the final InputEvent/textarea value as the canonical Unicode text. There is no punctuation-specific mapping.

Test plan

  • npm test — 5368 passed, 12 skipped
  • npm run test:browser -- test/terminal-copy-shortcut.test.ts — 8 passed
  • npm run typecheck
  • npm run lint
  • npm run format:check
  • npm run check:frontend-syntax
  • npm run check:public-assets
  • npm run build

The browser regression commits Chinese text first, then verifies each character in ,。!?;:“”、《》、() reaches terminal onData exactly once in both desktop and touch-capable contexts.

@Ark0N

Copy link
Copy Markdown
Owner

Thank you! This is the right root-cause fix. Returning false for keyCode 229 was stopping xterm before its CompositionHelper could diff the helper textarea, so the committed text never reached onData, and sending KeyboardEvent.key from the CJK field could never preserve what the IME actually committed. Delegating to xterm and treating the final input text as canonical also makes the old Android orphan-input fallback redundant, so removing it leaves exactly one input owner instead of a stack of double-send heuristics.

Verified locally on top of #331: full test gate green, and npm run test:browser -- test/terminal-copy-shortcut.test.ts passes (8 tests, including your new full-width punctuation regression on both desktop and touch-capable Chromium).

Merging, ships in 1.20.1.

@Ark0N
Ark0N merged commit abca552 into Ark0N:masterAug 21, 2026
2 checks passed
Sign up for freeto 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.

2 participants

@dignfei@Ark0N