macOS: Fix Korean composing text commit key handling#4478
Open
jayychoi wants to merge 1 commit intorust-windowing:masterfrom
Open
macOS: Fix Korean composing text commit key handling#4478jayychoi wants to merge 1 commit intorust-windowing:masterfrom
jayychoi wants to merge 1 commit intorust-windowing:masterfrom
Conversation
Fix space being inserted twice. Fix ASCII characters being dropped when typed during preedit state.
hiking90
added a commit
to hiking90/winit
that referenced
this pull request
Feb 22, 2026
Fix space being inserted twice. Fix ASCII characters being dropped when typed during preedit state. Cherry-picked from: rust-windowing#4478 Co-Authored-By: Jay Choi <[email protected]>
zilhak
added a commit
to zilhak/winit-ime-fix
that referenced
this pull request
Apr 1, 2026
Port of rust-windowing#4478 to v0.30.13. Bug 1 - Space double input: Clear marked_text immediately after commit to prevent subsequent insertText calls from being treated as IME commits. Bug 2 - Trigger key drop (comma, period, etc.): Remove the early return guard in doCommandBySelector when ImeState::Committed, which was swallowing ASCII key commands after IME commit. When upstream PR rust-windowing#4478 is merged and released, this fork should be replaced with the official winit release. Reference: rust-windowing#4478
zilhak
added a commit
to zilhak/tasty
that referenced
this pull request
Apr 1, 2026
winit의 macOS 백엔드 버그로 인해 한글 컴포징 후 트리거 키(콤마, 마침표 등)의 Pressed 이벤트가 누락되고, 스페이스가 이중 입력되던 문제를 애플리케이션 레벨 workaround로 처리하고 있었음. winit PR #4478의 수정을 v0.30.13에 포팅한 fork를 사용하여 근본 원인을 해결하고, 기존 ime_committed_text 기반 workaround 코드를 전부 제거. Fork: https://github.com/zilhak/winit-ime-fix (branch: fix-korean-ime) Upstream PR: rust-windowing/winit#4478
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.
changelogmodule if knowledge of this change could be valuable to usersSummary
A minimal fix that addresses a major pain point in macOS Korean IME handling.
Fixes two interrelated bugs reported downstream in Alacritty:
Spaceonce inserts two spacesWhen using CJK input method in MacOS, space is inserted twice per 1 stroke. alacritty/alacritty#8079
Keyboard input does not work with CJK IME (macOS, 0.12.1) alacritty/alacritty#6942
Root Cause
Bug 1: Double Space
When Space is pressed with Korean IME active but no active composition, macOS calls
setMarkedText(" ")followed byinsertTexttwice within the sameinterpretKeyEvents. The firstinsertTextcall setImeState::Committedbut did not clearmarked_text. The second call still sawhasMarkedText() == trueand emitted a duplicateIme::Commit(" ").Bug 2: Key Loss
doCommandBySelectorhad a blanket early-return guard whenImeState == Committed:This was originally added to prevent
Enterfrom being sent twice when used to confirm IME input. However, it was too aggressive — it swallowed ASCII key commands after a commit, preventingforward_key_to_appfrom being set. This caused trigger keys to be silently dropped.Fix
In
insertText:marked_textimmediately after committing, so subsequentinsertTextcalls within the sameinterpretKeyEventsno longer see stale preedit state.else if Committedbranch that setsforward_key_to_app = truefor post-commit characters, forwarding them as regular key events instead of duplicate IME commits.In
doCommandBySelector:Committedearly-return guard. Withmarked_textproperly cleared ininsertText, the double-input issue this guard was meant to prevent no longer occurs.Test Results (Korean IME)
Tested with the
imeexample (cargo run --example ime). Below are before/after comparisons for each Korean IME scenario.Space on empty field (Bug 1: double space)
"한" + Space commit (already worked)
"한" + Enter commit (already worked)
"한" + digit (Bug 2: key loss)
"한" + ASCII (Bug 2: key loss)
Impact on Other CJK IMEs
These changes only affect the Korean IME code path. Japanese and Chinese IMEs are not affected because:
doCommandBySelectoror trigger a secondinsertTextwithin the sameinterpretKeyEventscall.Committedstate is reset toGroundat the end of eachkeyDown, so the next keypress always starts fromGroundregardless of IME.Japanese and Chinese IMEs were tested and confirmed no regression (nihon→にほん, nihao→你好, emoji selection, etc.).