fix(extension): defer composing reset to stop CJK IME double-send#1679
Open
0xteng wants to merge 1 commit into
Open
fix(extension): defer composing reset to stop CJK IME double-send#16790xteng wants to merge 1 commit into
0xteng wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Typing CJK (Chinese / Japanese) through an IME in the sidebar terminal chat
sends every committed segment twice. Typing "在这里我可以做什么" renders as
"在在这里这里我我可以可以做做什么什么".
Root cause
The IME composition handling added for the Korean work (#1272, PR #1297) lives
in
extension/sidepanel-terminal.js, but it clearscomposing = falsesynchronously inside the
compositionendhandler, before sending.Browsers fire the trailing
inputevent (→ xtermterm.onData) immediatelyafter
compositionend, carrying the same composed string. By thencomposingis already
false, so theif (composing) return;guard inonDatano longersuppresses it, and the text is
ws.send-ed a second time.Korean composition (tested in #1297) doesn't surface this, but languages that
commit per-segment and fire a trailing
inputevent — Chinese, Japanese — getevery segment doubled.
Fix
Defer the
composing = falsereset to the next tick withsetTimeout(…, 0),so the
onDataevent that fires right aftercompositionendis stillsuppressed. One-line behavioral change; the Korean path from #1297 is
unaffected.
Testing
Manually verified in the GStack Browser sidebar (v1.44). Before:
"在这里我可以做什么" rendered as "在在这里这里我我可以可以做做什么什么".
After the fix: renders once, correctly. English input/output unaffected.