Repository navigation
W40: macOS: Korean input drops characters when the input method replaces text - #32
moneycode11101-svg wants to merge 1 commit into
Conversation
Apple Korean doesn't use marked text: every key calls `insertText:replacementRange:`, replacing the syllable typed so far. The `PlainInsert::KeyText` branch leaves the key's text to its `KeyboardInput`, but keyDown drops that event when the same key also committed (`committed_in_key_down`) or enabled IME. The text never reached the app, while `ImeDocument` and the input method count it, so the next replacement deleted a character the app does have: spaces vanished and the previous syllable was overwritten. Text the app hasn't received is kept in `deferred_key_text`. A replacement deletes only what reached the app, and keyDown commits the text when it drops the key event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested with a real keyboard: macOS 27, Apple 2-Set Korean, GridCraft 0.18.0 built against this PR's head (ae9f727). That is the same base GridCraft 0.18.0 pins (a517b38), so the only winit change is this PR. The GridCraft build also had storytold/gridcraft#1632 ported onto 0.18.0. Before (a517b38): typing With this PR, all of these came out as typed:
I also traced the Not tested: #15 itself, other Korean layouts (3-Set, Romaja), and anything outside GridCraft. |
| | W25 | `eb4007da` | X11/Wayland: `platform::latin_layout::KeyEventExtLatinLayout`, the key on the first Latin layout group for shortcuts on non-Latin layouts | none; to be proposed | upstream release with an equivalent | storytold/winit PR #5; craft-libs#198 (K2) | | ||
| | W26 | `2b9cd1cf` | macOS: replaced text is deleted by UTF-8 byte count with the commit (`WindowExtMacOS::take_ime_delete_surrounding`, same shape as W27) | master: `Ime::DeleteSurrounding` (a new `Ime` variant breaks 0.30 matchers) | the egui → 0.31 move | storytold/winit PR #6 (`d103edae`) | | ||
| | W27 | `f40c76a2` | Wayland: text-input-v3 surrounding text (`WindowExtWayland::set_ime_surrounding_text`, `set_ime_surrounding_text_with_change_cause`, `clear_ime_surrounding_text`), delete-surrounding attached to the commit (`take_ime_delete_surrounding` → `ImeDeleteSurrounding { before_bytes, after_bytes }`), per-seat preedit ownership and outgoing state waiting for a matching `done` (E21b) | master has both as core API (`Ime::DeleteSurrounding`) | the egui → 0.31 move | storytold/winit PR #7; craft-libs#198 (I7) | | ||
| | W40 | `korean-keytext` | macOS: Apple Korean's key text left to a `KeyboardInput` that keyDown drops (same key committed or enabled IME) is committed instead, and replacements don't delete it from the app (spaces vanishing, previous syllable overwritten) | none; to be proposed | upstream fix | storytold/winit PR (this branch); filmcraft C | |
There was a problem hiding this comment.
The W40 row names only Apple Korean, but the same patch fixes Apple Vietnamese too (Space after a syllable lost, storytold/wordcraft#3569). Consider naming both, so the row says what to re-test before dropping the patch:
| | W40 | `korean-keytext` | macOS: Apple Korean's key text left to a `KeyboardInput` that keyDown drops (same key committed or enabled IME) is committed instead, and replacements don't delete it from the app (spaces vanishing, previous syllable overwritten) | none; to be proposed | upstream fix | storytold/winit PR (this branch); filmcraft C | | |
| | W40 | `korean-keytext` | macOS: key text that Apple Korean or Apple Vietnamese inserts is left to a `KeyboardInput` that keyDown drops (same key committed or enabled IME); it is committed instead, and replacements don't delete it from the app (Korean: spaces vanishing, previous syllable overwritten; Vietnamese: the Space after a syllable lost) | none; to be proposed | upstream fix | storytold/winit PR (this branch); filmcraft C; wordcraft#3569 | |
|
Tested with Apple's Vietnamese input method: this PR also fixes storytold/wordcraft#3569 (the Space after a Vietnamese syllable is lost). Apple Vietnamese (Telex) uses marked text. From reading Setup: macOS 26.6.2, Apple Silicon, input source Vietnamese – Telex, real keyboard. WordCraft v0.17.0 built with its
|
|
Tested the Steps: type Before (a517b38): the field ends as With this PR's That matches the retry trace in the comment above: the key arrives once as Setup: macOS 26.6.2, Apple Silicon, Apple 2-Set Korean, an egui 0.37.0 Not tested: continuous typing with this PR, #15, anything outside the test app. Written with AI assistance (Claude). |
|
Tested in FilmCraft: v0.20.1 built with the winit pin changed to this PR's head (ae9f727), nothing else changed. macOS 27.2.1, Apple Silicon, Apple 2-Set Korean, real keyboard. Before (a517b38): typing Not tested: other input methods, #38. Reported as storytold/filmcraft#4954. |
Korean input on macOS drops characters when the input method replaces text via
insertText:replacementRange:: spaces vanish, the previous syllable is overwritten, and syllables come out shuffled.Apple's Korean input methods (2-Set and the others) don't use marked text. Every key calls
insertText:replacementRange:, replacing the syllable typed so far with the updated one, and a syllable ends withinsertTextof it followed by the Space or the next jamo.Cause. In
insertText, thePlainInsert::KeyTextbranch leaves the key's text to the key'sKeyboardInput(sent at the end ofkeyDown:). ButkeyDown:doesn't send that event when the same key press also committed (committed_in_key_down, W9) or moved IME from Disabled to Ground. The text never reaches the app, whileImeDocumentand the input method count it, so the next replacement deletes a character the app does have.deferred_key_textuntil it reaches the app.replaceddeletes only the part of the replaced range that reached the app, and whenkeyDown:doesn't send theKeyboardInput, it commits the remembered text withIme::Commit. PATCHES.md row W40.tests/ime_patches.rs:macos_korean_key_text_survives_a_replacementguards the three places (remembering the text ininsertText, the commit inkeyDown:, and the reduced deletion inreplaced). The char-boundary step avoidsstr::floor_char_boundaryto keep the 1.70 MSRV.Reproduce: macOS, input source Korean 2-Set, in an egui text field (egui-winit with W26's
take_ime_delete_surrounding), type이제 대로 이게 됨(dlwp eofh dlrp ehla). Before: spaces disappear and syllables are overwritten or swapped. After: the text is exactly이제 대로 이게 됨.Tested on macOS (Apple Silicon) in FilmCraft C built against this branch:
cargo test --test ime_patches: 45 passed (44 existing + 1 new);cargo test --lib: 25 passed;cargo clippy --all-targetsis clean.이제 대로 이게 됨comes out exactly, both in a custom eguiTextEditpanel and in FilmCraft's own Markers search field; Backspace then edits the last syllable (됨→되)hello world, Backspace and Enter: work as before (ABC layout, Markers search field)Not tested: Korean 3-Set and other replacement-based input methods (Vietnamese), Japanese/Chinese (they use marked text, which this change doesn't touch), dictation. Other platforms are untouched.
🤖 Generated with Claude Code