Skip to content

Handle IME-transformed printable input - #6024

Open
yasuhito wants to merge 1 commit into
xtermjs:masterfrom
yasuhito:fix/skk-beforeinput-printable-defer
Open

Handle IME-transformed printable input#6024
yasuhito wants to merge 1 commit into
xtermjs:masterfrom
yasuhito:fix/skk-beforeinput-printable-defer

Conversation

@yasuhito

Copy link
Copy Markdown

Fixes #5348

This changes printable key handling to give beforeinput/input a chance to provide the authoritative text before xterm.js sends the raw keydown character.

Some IMEs such as SKK commit certain characters without a compositionstart/compositionend sequence. In Chromium-based runtimes, a key like a can arrive as:

  • keydown: raw key a
  • beforeinput/input: committed IME text

Before this change, xterm.js sent the raw keydown text immediately, so terminal apps received a instead of . Multi-key SKK input such as ka can still work because the first key enters IME state and the committed text arrives later.

The fix:

  • defers unmodified, single-character printable keydown data for one tick
  • handles beforeinput first, preventing the DOM mutation when possible
  • falls back to input if beforeinput is unavailable
  • flushes the original keydown text if no text input event arrives
  • leaves Kitty keyboard protocol, Win32 input mode, modified keys, control sequences, and screen reader mode on the existing synchronous path

Added unit coverage for:

  • IME-transformed beforeinput data replacing raw printable keydown data (a -> )
  • regular printable text still being sent (a -> a)
  • fallback when no beforeinput/input arrives
  • special keyboard modes not being deferred

Validation run locally:

  • npm run build
  • npm run esbuild
  • node ./bin/test_unit.js out-esbuild/browser/Terminal.test.js
  • npm run test-unit
  • npm run lint-changes

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.

In macOS Chrome + AquaSKK (Input Method), Some characters will not converted by IM

1 participant