Skip to content

fix(grove): fix Korean Hangul IME composition with Shift in terminal#54

Merged
bang9 merged 2 commits intobang9:mainfrom
DongGukMon:fix/grove-hangul-input
Mar 28, 2026
Merged

fix(grove): fix Korean Hangul IME composition with Shift in terminal#54
bang9 merged 2 commits intobang9:mainfrom
DongGukMon:fix/grove-hangul-input

Conversation

@DongGukMon
Copy link
Copy Markdown
Contributor

Summary

  • Fix Korean display in terminal on systems with malformed locale (bare UTF-8 rejected, tmux -u flag added, LANG/LC_CTYPE propagated)
  • Fix Shift breaking Korean IME composition in terminal — characters requiring Shift (ㅆ, ㅖ, ㅃ, etc.) were impossible to type

Root cause

The xterm.js WKWebView patch (xtermjs/xterm.js#5704, not yet merged upstream) flushes pending IME composition on any non-229 keydown in _keyDown:

this._wkImeComposing && e.keyCode !== 229 && this._wkFlush(true)

This includes modifier keys (Shift=16, Ctrl=17, Alt=18, etc.), which prematurely sends the composing text to the PTY and breaks composition for Shift-required Korean characters.

Fix

Add modifier key exceptions to the _wkFlush guard in both xterm.js and xterm.mjs entry points:

this._wkImeComposing && e.keyCode !== 229
  && e.keyCode !== 16   // Shift
  && e.keyCode !== 17   // Ctrl
  && e.keyCode !== 18   // Alt
  && e.keyCode !== 20   // CapsLock
  && e.keyCode !== 91   // Left Meta
  && e.keyCode !== 93   // Right Meta
  && this._wkFlush(true)

Changed files

  • grove/grove-core/src/pty.rs — locale fix + tmux UTF-8 flags
  • grove/patches/@xterm__xterm.patch — modifier key exception in xterm.js WK IME flush
  • grove/pnpm-lock.yaml — patch hash update

Test plan

  • Type Korean characters requiring Shift (ㅆ, ㅖ, ㅃ, ㅉ, ㄸ) in grove terminal — composition should not break
  • Type normal Korean characters (ㅅ, ㅏ, ㅇ) — should work as before
  • Verify pnpm install && pnpm tauri dev builds and runs correctly

…locale

- Reject bare "UTF-8" as unusable locale in preferred_utf8_locale(),
  falling through to "C.UTF-8" (LANG=UTF-8 is not a valid POSIX locale
  and causes zsh/tmux to mishandle multi-byte input)
- Add -u flag to tmux new-session and attach-session to force UTF-8
- Propagate LANG and LC_CTYPE into tmux session environment so the
  shell inside tmux gets a proper UTF-8 locale
…minal

The xterm.js WKWebView patch (PR #5704) flushes pending IME composition
on any non-229 keydown, including modifier keys. This causes Shift-
required Korean characters (ㅆ, ㅖ, ㅃ, etc.) to break composition.

Add modifier key exceptions (Shift, Ctrl, Alt, CapsLock, Meta) to the
_wkFlush guard in both xterm.js and xterm.mjs entry points.
@bang9 bang9 merged commit 8f236a8 into bang9:main Mar 28, 2026
1 check passed
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.

2 participants