claude-code - 💡(How to fix) Fix [BUG] IME pre-edit buffer cleared by UI redraws during candidate selection — McBopomofo / 小麥注音, macOS, iTerm2 [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47962Fetched 2026-04-15 06:37:20
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Author
Timeline (top)
labeled ×5commented ×2cross-referenced ×1

Root Cause

English users don't hit this because each keystroke commits immediately. CJK IME users pay this tax every single turn.

Fix Action

Fix / Workaround

  • Trigger is UI redraw, not keystroke handling. Typing keys alone works fine — it's assistant output that destroys the composition.
  • macOS built-in Dictation has the same symptom on CJK layouts (dictation writes into the same pre-edit buffer, gets wiped by redraws).
  • Only reliable workaround: compose Chinese in another app, then paste. Defeats interactive CLI UX.
RAW_BUFFERClick to expand / collapse

What's Wrong?

When typing Chinese via an IME in Claude Code, the pre-edit buffer is destroyed by UI redraws during the uncommitted composition phase — after phonetic input is complete but before the user has finalized which characters to commit.

Concrete example with McBopomofo (小麥注音): I type ㄔㄥˊ ㄕˋ. McBopomofo uses inline pre-edit rendering — it shows the top-guess characters directly in the composition area (e.g. "程式") without a floating candidate popup. From here I can cycle through alternative homophones (e.g. 城市, 成事) using the up/down arrow keys, or press Enter to commit the current choice. If the assistant emits any new token before I commit, the entire pre-edit is wiped — typed Zhuyin input and current candidate both gone.

This is different from #43381 (characters invisible during typing). In my case, characters DO render inline while typing — the bug is that composition state isn't preserved across redraws while I'm still selecting among homophones.

What Should Happen?

The IME pre-edit buffer should survive assistant-driven redraws. Composition should only end on explicit user action: compositionend (commit via Enter / Space / number selection) or cancel (Esc). This is how readline, vim, and every modern TUI behave.

Steps to Reproduce

  1. macOS with McBopomofo (小麥注音, https://mcbopomofo.openvanilla.org/) as the active input source.
  2. Launch claude in iTerm2.
  3. Send a prompt that produces a long streaming response (e.g. write a 500-word essay).
  4. While Claude is streaming, in McBopomofo type ㄔㄥˊㄕˋ — a homophone resolving to 程式 (program) / 城市 (city) / 成事 (succeed). Leave the pre-edit uncommitted (do not press Enter; cycle candidates via up/down arrow keys).
  5. Observe: on the next assistant-driven redraw, the pre-edit is wiped. Input field is empty again.

Expected: Pre-edit survives redraws; I can pick 程式 vs 城市 on my own schedule. Actual: Composition state destroyed mid-selection; typed input lost.

Environment

  • Claude Code: 2.1.107
  • macOS: 15.7.4 (Sequoia, Apple Silicon)
  • Terminal: iTerm2 3.6.9
  • Shell: zsh
  • IME: McBopomofo 小麥注音 (popular third-party Zhuyin IME in Taiwan)
  • Likely also affects: macOS native 注音 / 拼音, and any CJK IME that uses a pre-edit composition buffer.

Impact / Use Case

The primary workflow this breaks: while Claude is streaming a response, I want to compose my next prompt so I'm ready to send the moment the assistant finishes — making use of the otherwise-idle waiting time. This is a natural productivity pattern in any chat UI.

For CJK IME users this is impossible. Every streamed token triggers a redraw that destroys my in-progress composition while I'm still cycling candidates. The only options are:

  • (a) Sit idle while Claude works, then start typing from scratch after the stream ends — wasted time on every turn.
  • (b) Compose in another app and paste — defeats the interactive CLI UX.

English users don't hit this because each keystroke commits immediately. CJK IME users pay this tax every single turn.

Additional Context

  • Trigger is UI redraw, not keystroke handling. Typing keys alone works fine — it's assistant output that destroys the composition.
  • macOS built-in Dictation has the same symptom on CJK layouts (dictation writes into the same pre-edit buffer, gets wiped by redraws).
  • Only reliable workaround: compose Chinese in another app, then paste. Defeats interactive CLI UX.

extent analysis

TL;DR

The pre-edit buffer in Claude Code is destroyed by UI redraws during the uncommitted composition phase when using a CJK IME, and a potential fix involves preserving the composition state across redraws.

Guidance

  • Investigate how Claude Code handles UI redraws and composition state, focusing on the interaction between the assistant's output and the IME's pre-edit buffer.
  • Consider implementing a mechanism to temporarily suspend or buffer the assistant's output while the user is in the process of composing a prompt with a CJK IME.
  • Look into existing solutions or workarounds used in other terminal emulators or chat UIs that support CJK IMEs, such as readline or vim.
  • Verify that the issue is specific to Claude Code and not a general problem with the McBopomofo IME or macOS's input handling.

Example

No specific code example can be provided without more information about Claude Code's internal implementation, but a potential approach might involve using a separate data structure to store the composition state and updating it only when the user explicitly commits or cancels the composition.

Notes

The issue seems to be specific to CJK IMEs and the way they handle pre-edit composition buffers, which may require a tailored solution. Additionally, the problem may not be limited to Claude Code, as similar issues are reported with macOS's built-in Dictation feature.

Recommendation

Apply a workaround that involves composing Chinese text in another app and pasting it into Claude Code, as this is the only reliable solution currently available. However, this defeats the interactive CLI UX, and a more permanent fix should be investigated to preserve the composition state across redraws.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] IME pre-edit buffer cleared by UI redraws during candidate selection — McBopomofo / 小麥注音, macOS, iTerm2 [2 comments, 2 participants]