Skip to content

fix(launcher): ignore IME composition Enter so CJK input does not submit the search - #639

Open
YuriNachos wants to merge 1 commit into
SuperCmdLabs:mainfrom
YuriNachos:YuriNachos/w3-supercmd
Open

fix(launcher): ignore IME composition Enter so CJK input does not submit the search#639
YuriNachos wants to merge 1 commit into
SuperCmdLabs:mainfrom
YuriNachos:YuriNachos/w3-supercmd

Conversation

@YuriNachos

Copy link
Copy Markdown

Fixes #637
(Also resolves its duplicate #296.)

What changed

Guard the main launcher search input's handleKeyDown against CJK IME
composition. Added a small pure predicate isImeComposing(nativeEvent, keyCode)
in src/renderer/src/utils/keyboard.ts and made it the first check in
handleKeyDown (src/renderer/src/hooks/useLauncherKeyboardControls.ts):
while an Input Method Editor composition is in progress (KeyboardEvent.isComposing === true,
or the legacy keyCode === 229), the handler returns early without
preventDefault, so the Enter that confirms a kana-kanji / pinyin candidate
is no longer treated as a submit.

Why

While composing Japanese/Chinese/Korean text, the Enter that confirms the IME
candidate arrives as a normal-looking Enter but with isComposing === true.
With no guard, that Enter hit case 'Enter':e.preventDefault() → the
selected command ran / the window hid, mid-composition — making the launcher
unusable for CJK input. The sibling handler in QuickLinkManager.tsx:913
already guards with event.isComposing; the main search input was missing the
same guard. This brings it to parity via an extracted, unit-testable predicate.

Compatibility impact

No impact on Raycast extensions — this is launcher chrome (the main search
input's React keydown handler), not the @raycast/api / @raycast/utils
compatibility shim. Non-IME users see identical behavior: isImeComposing is
only true during an active composition (or a legacy 229 keydown), so no
ordinary keystroke is swallowed.

How tested

  • New scripts/test-ime-composition.mjs (mirrors
    test-exec-command-timeout-cleanup.mjs, imports the real predicate via
    esbuild): 6 assertions, all pass — including
    isImeComposing({isComposing:true}, 13) === true,
    isImeComposing({}, 229) === true,
    isImeComposing({isComposing:false}, 13) === false.
  • npm test → 88 tests, 87 pass, 0 fail.
  • npm run build:main and npm run build:renderer (vite) → exit 0.
  • npm run check:i18n → exit 0 (no strings changed).
  • tsc -p tsconfig.renderer.json --noEmit delta vs main = 0 (the change
    adds no type errors; pre-existing renderer debt is unchanged).

…mit the search

handleKeyDown had no IME guard, so the Enter that confirms a CJK (Japanese/Chinese/Korean) IME composition candidate was misread as submit and closed/ran the launcher mid-composition. Add a pure, unit-tested isImeComposing predicate (checks the DOM isComposing flag and the legacy keyCode 229) and make it the first check in handleKeyDown (early-return while composing).

Fixes SuperCmdLabs#637
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.

IME composition is being ignored while entering commands

1 participant