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.
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.).