Repository navigation
Conversation
…opped Pressing Enter while an IME composition is still active (Korean, Japanese, Chinese, etc.) sent the prompt before the composition was committed, so the last character was missing from the sent message (and often stayed behind in the input). Defer the send to the compositionend event instead. A short timeout clears the pending flag if the composition never ends, and the regular Enter path clears it as well so the prompt is never sent twice.
ljk0071
force-pushed
the
fix/ime-composition-last-char
branch
from
November 12, 2026 07:57
886082e to
707dea3
Compare
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
With an IME-based layout (reproduced on macOS with the Korean 2-set IME, but the same applies to Japanese/Chinese and other composing input methods), pressing
Enterwhile a composition is still active fires akeydownwithisComposing === true/keyCode === 229. The handler calledhandleSend()right away, before the IME had committed the composing character.As a result the prompt was sent without its last character (e.g. typing
안녕하세요and pressing Enter sent안녕하세), and the missing character was usually left behind in the input box.Fix
Defer the send until the composition has been committed:
Enterkeydown withisComposing === true(orkeyCode === 229) no longer sends immediately; it only marks the send as pending,compositionendhandler then sends once, on the next tick, sotextarea.valuealready contains the committed character,Enterpath clears the pending flag, so a secondkeydownnever sends the prompt twice,compositionendever arrives.This is related to #75, which ignores the composing keydown and relies on a second, non-composing
keydownto send. This patch also handles IMEs that only deliver the composing keydown, while the pending-flag reset keeps the double-send from #75 fixed.Testing
npx tsc -p . --noEmit— passesnpx eslint src --max-warnings 0— passesnpm run compile— passesNon-IME input is unchanged: plain
Enterstill sends andShift+Enterstill inserts a newline.