Skip to content

W28: macOS: commit a key's jamo inserted after a commit in the same key press - #15

Open
Fuzen2478 wants to merge 1 commit into
storytold:craft/0.30.13from
Fuzen2478:fix/macos-korean-jamo-after-commit
Open

Fuzen2478 wants to merge 1 commit into
storytold:craft/0.30.13from
Fuzen2478:fix/macos-korean-jamo-after-commit

Conversation

@Fuzen2478

@Fuzen2478 Fuzen2478 commented Oct 27, 2026 •

Copy link
Copy Markdown

Problem

Typing Korean with Apple 2-Set Korean loses the syllable before each new one: 안녕하세요 comes out as 녕하세요 (GridCraft, macOS 27, real keyboard; the in-cell editor and the formula bar alike).

On this setup Apple Korean doesn't use marked text with the winit view. For the key that starts a new syllable it calls:

  1. insertText("안", replacementRange): the finished syllable, a replacement. Committed (Ime::Commit + take_ime_delete_surrounding), so committed_in_key_down = true.
  2. insertText("ㄴ", NSNotFound): the key's own jamo, equal to the key's characters, so plain_insert returns KeyText. It goes into ImeDocument and is left to the key's KeyboardInput.

keyDown: doesn't send that KeyboardInput, because the key committed text (W9, committed_in_key_down). The app never gets ㄴ. The next key replaces ㄴ with 녀 (delete 3 bytes + commit), and those 3 bytes are 안 in the app.

Events the app received for d k s s u d (안녕), before the fix:

DeleteSurroundingBytes(3) Commit("아")
DeleteSurroundingBytes(3) Commit("안")
DeleteSurroundingBytes(3) Commit("안")            <- second s: ㄴ missing
DeleteSurroundingBytes(3) Commit("녀")            <- deletes 안
DeleteSurroundingBytes(3) Commit("녕")

Fix

KeyText is committed like Commit when a commit already went out during the key press, since no KeyboardInput will carry it. After the fix the third line is DeleteSurroundingBytes(3) Commit("안") Commit("ㄴ") and 안녕하세요 is typed correctly.

  • src/platform_impl/macos/view.rs: the KeyText arm is guarded by !committed_in_key_down; otherwise it takes the commit arm.
  • tests/ime_patches.rs: macos_jamo_typed_after_a_commit_is_committed (fails without the fix).
  • PATCHES.md: W28.

Verification

  • cargo test --test ime_patches: 45 passed (the new guard fails without the change).
  • cargo clippy --lib --tests: clean. cargo +nightly fmt applied.
  • GridCraft with this winit (path patch), macOS 27, Apple 2-Set Korean, physical keyboard: 안녕하세요 typed over a cell and in the in-cell editor after F2 is entered whole. Synthetic key codes (g k s r m f) give 한글 (was 글).

Related

storytold/gridcraft#2735 fixes the other half, in GridCraft (the start of a cell split the first syllable). Once this merges, GridCraft's [patch] rev for winit needs a bump.

…ey press

Apple Korean answers the key that starts a new syllable with insertText of the
finished syllable (a replacement, so a commit) and then insertText of the key's
own jamo. That second text matched the key's characters, so it was left to the
key's KeyboardInput, which keyDown doesn't send once the key committed text
(W9). The jamo was lost and the next replacement deleted the syllable before
it: "안녕하세요" typed "녕하세요".

The key's text is committed when a commit already went out during the key
press. Guarded by tests/ime_patches.rs.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewerA — source-read COMMENT (not an approval)

I read the hunk: in the macOS insertText handler, the plain-key-text branch is skipped when a commit was already sent during the same key press (committed_in_key_down), because keyDown: doesn't send that key's KeyboardInput after a commit, and Apple Korean IME commits the syllable and then inserts the next jamo, which was dropped. The condition is a narrow, well-commented guard. I can't run an IME here; please include a test with the Korean sequence in the description, and confirm the skipped branch's delete of the replaced range doesn't also have to happen when the jamo is committed on the other path.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants