Repository navigation
Conversation
Three fixes for NSTextInputClient protocol implementation on macOS: 1. validAttributesForMarkedText now returns standard attributes (NSUnderlineStyle, NSMarkedClauseSegment) instead of an empty array. Some IMEs (e.g. 落格输入法) require non-empty return to enter composition mode. 2. insertText:replacementRange: no longer gates commit on hasMarkedText(). Some IMEs call unmarkText before insertText, which clears the marked text and caused all commits to be silently discarded. According to Apple docs, insertText should insert the provided string regardless of marked text state. 3. Added pending_commit flag to distinguish genuine composition commits from regular typing during IME mode (spaces, English chars), which should go through keyboard input instead of Ime::Commit.
7 tasks
echelon
added a commit
to storytold/pdfcraft
that referenced
this pull request
Oct 10, 2026
… (winit#4650) (#676) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of #4651 (merged on winit master), plus the part of #4748 that fixes #4651's out-of-key-press case (#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
echelon
added a commit
to storytold/pdfcraft
that referenced
this pull request
Oct 10, 2026
* macOS: IME text committed after the marked text is cleared isn't lost (winit#4650) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of #4651 (merged on winit master), plus the part of #4748 that fixes #4651's out-of-key-press case (#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * macOS: emoji from the emoji picker reach text fields (winit#4749) The macOS emoji picker (Fn/Globe-E, Control-Command-Space) inserts its text with insertText:replacementRange: outside any key press and without a composition. winit 0.30.13 reports insertText only as part of a key press or a composition, so an emoji picked into Search, a form field or a comment was dropped. vendor/winit now reports text inserted outside a key press, with IME allowed and no composition, as Ime::Commit, as rust-windowing/winit#4749 (the 0.30 backport of #4748) does. Builds on the pending_commit and in_key_down state of the previous macOS IME change. #4748's selectedRange change, which lets dictation start, is left out: checked on macOS 14.7.1, a valid selection switches on press-and-hold for every held key in a winit window, so holding e kept sending e key events under an accent menu, and the accent picked with 1 arrived as a separate commit after "eeee…1". Without it, held keys repeat as before. Checked with a scratch winit app on macOS 14.7.1: an insertText outside a key press now arrives as Ime::Commit; held keys, ABC, Japanese, Cangjie and Korean typing give the same events as before. A test fails if a re-vendored winit loses the patch or gains the selectedRange change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
echelon
added a commit
to storytold/pdfcraft
that referenced
this pull request
Oct 10, 2026
…pace (winit#4478) (#679) * macOS: IME text committed after the marked text is cleared isn't lost (winit#4650) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of #4651 (merged on winit master), plus the part of #4748 that fixes #4651's out-of-key-press case (#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * macOS: Space in Apple Korean with no syllable in progress types one space (winit#4478) With Apple Korean 2-Set on macOS 14, Space with no syllable in progress (a second space, or a space after a digit or punctuation) makes AppKit call setMarkedText(" "), insertText(" "), then setMarkedText(""). winit reports the insertText as Ime::Commit(" "), but the trailing empty setMarkedText returns its state to the ground state, so keyDown also sends the key as KeyboardInput with text " ". egui inserts both, and PdfCraft's text fields got two spaces (the double space of alacritty/alacritty#8079). vendor/winit now records that the key being handled committed IME text and then doesn't also send it as KeyboardInput, unless AppKit forwards it as a command through doCommandBySelector (Enter after a syllable still commits the syllable and sends Enter). keyDown consumes the record on every key, so keys typed after IME is disallowed are unaffected. rust-windowing/winit#4478 aims at the same double space, but its changes (clearing the marked text on commit, forwarding a later insertText, and dropping doCommandBySelector's guard) don't reach this call order, and the key loss it also fixes is already fixed by the previous change (pending_commit). This is the narrow form for the call order observed here; it should go upstream with #4478. Checked with the real input methods on macOS 14.7.1 (scratch winit app, on top of the previous change): the duplicate KeyboardInput Space is gone and nothing else changes (Korean syllables, 한+Enter, 한+5, Japanese, Cangjie, ABC, held keys, keys after IME is disallowed). A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep #678's emoji-picker branch: view.rs is main's plus this PR's Space fix (54b3d3c) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
echelon
added a commit
to storytold/pdfcraft
that referenced
this pull request
Oct 10, 2026
…#4744) (#680) * macOS: IME text committed after the marked text is cleared isn't lost (winit#4650) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of #4651 (merged on winit master), plus the part of #4748 that fixes #4651's out-of-key-press case (#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * macOS: the first Apple Korean key in a fresh PdfCraft composes (winit#4744) On the first key after PdfCraft starts, Apple Korean 2-Set can answer interpretKeyEvents with insertText and the raw compatibility jamo instead of setMarkedText. winit sends that key to the app as an ordinary key, and the next keys compose without it: g k s Space typed ㅎㅏㄴ instead of 한 (Search, form fields, comments; rust-windowing/winit#3095). vendor/winit now ports rust-windowing/winit#4744: keyDown interprets that one key a second time, synchronously, before any KeyboardInput is sent, and only when every condition holds: Apple Korean, IME allowed and not yet composing, no pending commit or marked text, no Command/Control/Option, not a repeat, the key window's first responder, the only callback is one insertText of that same single jamo, and focus and input source unchanged afterwards. The decision is ImeStartup (ime_startup.rs, copied with its seven tests); no timer, no key queue, no text rewriting. It sits on top of the previous macOS IME change (pending_commit, in_key_down); the retry runs inside in_key_down. Command maps to ModifiersState::SUPER in winit 0.30 (META on winit master). Checked with the real input method on macOS 14.7.1 (scratch winit app, fresh process each time): without the patch g k s Space gave ㅎ as a key, then ㅏ and ㄴ committed separately, 3 runs out of 3; with it, ㅎ → 하 → 한 → 한 committed, 3 out of 3. All other traces (Japanese, Cangjie, ABC, held keys, later Korean keys) are unchanged. ImeStartup's tests pass with rustc --test. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
krichelj
pushed a commit
to krichelj/pdfcraft
that referenced
this pull request
Oct 11, 2026
… (winit#4650) (storytold#676) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of storytold#4651 (merged on winit master), plus the part of storytold#4748 that fixes storytold#4651's out-of-key-press case (storytold#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
krichelj
pushed a commit
to krichelj/pdfcraft
that referenced
this pull request
Oct 11, 2026
…orytold#678) * macOS: IME text committed after the marked text is cleared isn't lost (winit#4650) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of storytold#4651 (merged on winit master), plus the part of storytold#4748 that fixes storytold#4651's out-of-key-press case (storytold#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * macOS: emoji from the emoji picker reach text fields (winit#4749) The macOS emoji picker (Fn/Globe-E, Control-Command-Space) inserts its text with insertText:replacementRange: outside any key press and without a composition. winit 0.30.13 reports insertText only as part of a key press or a composition, so an emoji picked into Search, a form field or a comment was dropped. vendor/winit now reports text inserted outside a key press, with IME allowed and no composition, as Ime::Commit, as rust-windowing/winit#4749 (the 0.30 backport of storytold#4748) does. Builds on the pending_commit and in_key_down state of the previous macOS IME change. storytold#4748's selectedRange change, which lets dictation start, is left out: checked on macOS 14.7.1, a valid selection switches on press-and-hold for every held key in a winit window, so holding e kept sending e key events under an accent menu, and the accent picked with 1 arrived as a separate commit after "eeee…1". Without it, held keys repeat as before. Checked with a scratch winit app on macOS 14.7.1: an insertText outside a key press now arrives as Ime::Commit; held keys, ABC, Japanese, Cangjie and Korean typing give the same events as before. A test fails if a re-vendored winit loses the patch or gains the selectedRange change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
krichelj
pushed a commit
to krichelj/pdfcraft
that referenced
this pull request
Oct 11, 2026
…pace (winit#4478) (storytold#679) * macOS: IME text committed after the marked text is cleared isn't lost (winit#4650) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of storytold#4651 (merged on winit master), plus the part of storytold#4748 that fixes storytold#4651's out-of-key-press case (storytold#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * macOS: Space in Apple Korean with no syllable in progress types one space (winit#4478) With Apple Korean 2-Set on macOS 14, Space with no syllable in progress (a second space, or a space after a digit or punctuation) makes AppKit call setMarkedText(" "), insertText(" "), then setMarkedText(""). winit reports the insertText as Ime::Commit(" "), but the trailing empty setMarkedText returns its state to the ground state, so keyDown also sends the key as KeyboardInput with text " ". egui inserts both, and PdfCraft's text fields got two spaces (the double space of alacritty/alacritty#8079). vendor/winit now records that the key being handled committed IME text and then doesn't also send it as KeyboardInput, unless AppKit forwards it as a command through doCommandBySelector (Enter after a syllable still commits the syllable and sends Enter). keyDown consumes the record on every key, so keys typed after IME is disallowed are unaffected. rust-windowing/winit#4478 aims at the same double space, but its changes (clearing the marked text on commit, forwarding a later insertText, and dropping doCommandBySelector's guard) don't reach this call order, and the key loss it also fixes is already fixed by the previous change (pending_commit). This is the narrow form for the call order observed here; it should go upstream with storytold#4478. Checked with the real input methods on macOS 14.7.1 (scratch winit app, on top of the previous change): the duplicate KeyboardInput Space is gone and nothing else changes (Korean syllables, 한+Enter, 한+5, Japanese, Cangjie, ABC, held keys, keys after IME is disallowed). A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep storytold#678's emoji-picker branch: view.rs is main's plus this PR's Space fix (54b3d3c) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
krichelj
pushed a commit
to krichelj/pdfcraft
that referenced
this pull request
Oct 11, 2026
…#4744) (storytold#680) * macOS: IME text committed after the marked text is cleared isn't lost (winit#4650) winit 0.30.13 reports insertText as Ime::Commit only while marked text is left, and after any commit it swallows the next key. Real paths where that loses text: - input methods that end a composition with unmarkText, then insertText (rust-windowing/winit#3925): the committed text was dropped; - Apple Korean 2-Set, for the key typed after a syllable: on 한 then 5 it calls setMarkedText("한"), insertText("한"), setMarkedText(""), insertText("5"), so the 5 (or ;, or any key that ends the syllable) was dropped; - a commit made outside a key press (a candidate clicked with the mouse, dictation): no key follows to reset the state, so the next key (for example Backspace) was swallowed. vendor/winit now commits when a composition was started (pending_commit, set in setMarkedText, cleared by the commit and when IME is disallowed); other insertText calls still reach the app as KeyboardInput. A commit outside keyDown clears the marked text and returns to the ground state. validAttributesForMarkedText lists the underline and marked-clause attributes, which some input methods need before they compose. This is rust-windowing/winit#4650, the 0.30 backport of storytold#4651 (merged on winit master), plus the part of storytold#4748 that fixes storytold#4651's out-of-key-press case (storytold#4748's other parts are not included). One correction: upstream spells the underline attribute "NSUnderlineStyle", but AppKit's NSUnderlineStyleAttributeName is "NSUnderline" (printed on macOS 14), so the AppKit value is used. Checked with the real input methods on macOS 14.7.1 (a scratch winit app fed key events through AppKit): with the patch 한+5 and 한+; commit the 5 and ;, unmarkText-then-insertText commits, and Backspace after a commit outside a key press is delivered; ABC typing, held keys, Japanese (日本, あ), Cangjie (日) and Korean composition give the same events as before. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * macOS: the first Apple Korean key in a fresh PdfCraft composes (winit#4744) On the first key after PdfCraft starts, Apple Korean 2-Set can answer interpretKeyEvents with insertText and the raw compatibility jamo instead of setMarkedText. winit sends that key to the app as an ordinary key, and the next keys compose without it: g k s Space typed ㅎㅏㄴ instead of 한 (Search, form fields, comments; rust-windowing/winit#3095). vendor/winit now ports rust-windowing/winit#4744: keyDown interprets that one key a second time, synchronously, before any KeyboardInput is sent, and only when every condition holds: Apple Korean, IME allowed and not yet composing, no pending commit or marked text, no Command/Control/Option, not a repeat, the key window's first responder, the only callback is one insertText of that same single jamo, and focus and input source unchanged afterwards. The decision is ImeStartup (ime_startup.rs, copied with its seven tests); no timer, no key queue, no text rewriting. It sits on top of the previous macOS IME change (pending_commit, in_key_down); the retry runs inside in_key_down. Command maps to ModifiersState::SUPER in winit 0.30 (META on winit master). Checked with the real input method on macOS 14.7.1 (scratch winit app, fresh process each time): without the patch g k s Space gave ㅎ as a key, then ㅏ and ㄴ committed separately, 3 runs out of 3; with it, ㅎ → 하 → 한 → 한 committed, 3 out of 3. All other traces (Japanese, Cangjie, ABC, held keys, later Korean keys) are unchanged. ImeStartup's tests pass with rustc --test. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
This was referenced Oct 12, 2026
Contributor
Author
|
@kchibisov |
naoNao89
added a commit
to naoNao89/solidcraft
that referenced
this pull request
Oct 29, 2026
The string an input method hands over is committed while a composition is under way, not only while winit still holds marked text. A Vietnamese Telex syllable typed with the macOS input method ends with a space that never arrived: the input method clears its marked text first and hands that key over after, so the commit found nothing marked, and the key's own KeyboardInput was dropped as IME input as well. The space had to be typed twice. Through winit, egui-winit and an egui::TextEdit, "tieengs " leaves "tiếng" before this change and "tiếng " after it; a stock Cocoa NSTextView, given the same events and the same input source, holds "tiếng " either way. This is the backport of rust-windowing/winit#4651 (rust-windowing/winit#3925), merged into winit's master; the 0.30 backport rust-windowing/winit#4650 is still open and eframe 0.36 requires winit 0.30, so the vendored copy carries it. - ime_text.rs: `TextInput::insert_text` decides the commit from the composition it tracks instead of the marked text, so the string that ends a composition reaches the application. - the regression added in the previous commit passes; the plain-typing, control-character, disabled-IME and disallowed-IME cases are unchanged.
richerfu
pushed a commit
to richerfu/winit
that referenced
this pull request
Nov 2, 2026
Port of rust-windowing#4650 (0.30 backport of rust-windowing#4651, merged on master). Originally "M15.1: preserve macOS IME commits" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
This branch has not been deployed
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.
Summary
Fixes #3925 — macOS
insertText:replacementRange:incorrectly discards committed text when the IME callsunmarkTextbeforeinsertText, and when the IME requires a non-emptyvalidAttributesForMarkedTextto enter composition.Three targeted fixes in
src/platform_impl/macos/view.rs:1.
validAttributesForMarkedTextreturns standard attributesSome IMEs (e.g. 落格输入法 / LogInputMac3) require a non-empty return to enter composition mode. Apple's docs specify at minimum
NSUnderlineStyleAttributeNameandNSMarkedClauseSegmentAttributeName.2.
insertText:decouples marked-text clearing from commitThe old code required
hasMarkedText() == trueto commit, but some IMEs callunmarkTextbeforeinsertText(clearing the marked text), which silently discarded all committed text. Apple's documentation forinsertText:replacementRange:states that the provided string should be inserted regardless of whether there is marked text.Commit is now gated on
pending_commit && ime_enabledinstead ofhas_marked && ime_enabled.3.
pending_commitflag distinguishes composition commits from regular typingSimply removing the
hasMarkedTextcheck (as attempted in #4576) causes allinsertTextcalls — including spaces and English characters during IME mode — to go throughIme::Commit. This losesKeyboardInputevents and causes downstream visual artifacts (e.g. bracketed paste highlighting in Alacritty).The
pending_commitflag is set totrueinsetMarkedText:(only during actual composition) and checked + cleared ininsertText:. This ensures:pending_committrueIme::Commit✅falseKeyboardInput✅falseKeyboardInput(see notes)Related PRs
hasMarkedTextbut doesn't addpending_commit, causing all typing during IME to go throughIme::Commit— this breaks Russian layouts and creates paste artifacts.marked_textafter commit).Why
pending_commitis necessarykchibisov noted that removing the condition would lose
KeyboardInput, and checking for ASCII is wrong since Russian layout shouldn't go through IME. Thepending_commitflag ensures that only keystrokes that actually initiated a composition session result inIme::Commit— everything else preserves the existingKeyboardInputpath.This matches how Kitty's IME handling works: query IME first, then decide whether the key was consumed by composition or should be forwarded as a key event.
Tested