fix(tao): stop key roll-over from being read as a PressAndHold accent pick - #611
Closed
takke wants to merge 1 commit into
Closed
fix(tao): stop key roll-over from being read as a PressAndHold accent pick#611takke wants to merge 1 commit into
takke wants to merge 1 commit into
Conversation
… pick
Typing quickly on macOS silently dropped characters — "Xcode" landed as
"Xcde". Fast typists roll over: the previous key is still physically down
when the next one goes down, and `g_letter_key_down` only clears on the
*base* key's keyUp. Any selectedRange / attributedSubstring query arriving
in that window armed `g_press_and_hold_queried`, so the next `insertText:`
was routed into the replace-commit path — `deleteSurroundingTextInCodePoints(1, 0)`
ate the character that had just been committed and the new one took its
place.
The existing `!g_letter_key_down` reset never fired here: that flag is
precisely the one that stays YES through a roll-over.
Two guards, both resting on the same invariant — PressAndHold only ever
continues on the *same* physical key:
- `nucleus_note_press_and_hold_query` ignores queries that arrive while a
different key is being processed (`event.keyCode != g_base_key_code`).
- `nucleus_insert_text` drops any pending picker state when a different
letter key goes down. An accent is picked with a number key, the arrows
or the mouse — never a letter — so the real flow (repeat keyDown, then a
non-letter pick) is untouched.
Verified on a real Mac: "Xcode", repeated letters ("aaa"), and Japanese
IME input (ATOK / Kotoeri, NucleusFramework#595) all type cleanly.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
7 tasks
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.
Typing quickly on macOS silently drops characters. In our app (ZonePane, Compose text fields) typing
Xcodeat normal speed reliably lands asXcde— one character short, and the previous character is the one that disappears.This is not IME-specific: it hits plain ASCII typing, so every macOS Nucleus user is affected.
What happens
g_letter_key_downis only cleared on the base key'skeyUp(nucleus_key_up). Fast typists roll over — the previous key is still physically down when the next one goes down — so during ordinary typing that flag is YES for long stretches, with a different key already being processed.Any
selectedRange/attributedSubstringForProposedRangequery landing in that window runsnucleus_note_press_and_hold_query(), which checks onlyg_did_insert_base && g_letter_key_downand armsg_press_and_hold_queried. The nextinsertText:then matchesg_press_and_hold_queried && !sameAsBase && length > 0and is routed into the replace-commit path —deleteSurroundingTextInCodePoints(1, 0)eats the character that was just committed, and the new one takes its place.The existing reset
cannot help:
g_letter_key_downis precisely the flag that stays YES through a roll-over.Fix
Two guards, both resting on the same invariant — PressAndHold only ever continues on the same physical key, and its accent is picked with a number key, the arrows or the mouse, never with a letter:
nucleus_note_press_and_hold_query()ignores queries that arrive while a different key is being processed (event.keyCode != g_base_key_code), so ordinary typing no longer arms the picker.nucleus_insert_text()drops any pending picker state when a different letter key goes down, so even a stale flag cannot hijack a commit.The genuine flow is untouched: the picker engages on the base key's repeats (
isRepeat, same keyCode) and the accent arrives on a non-letter event.Testing
:decorated-window-tao:test/ktlintCheck/detekt/apiCheckall green.Xcodeand other fast-typed words now land intact; repeated letters (aaa,ee) are fine; Japanese IME input via ATOK and Kotoeri (Tao/macOS: IME marked text (preedit) never reaches Compose, and the commit Enter is delivered as a raw KeyDown — CJK input is unusable #595) still types cleanly — preedit, commit and arrow keys all behave.Related: #595, #596, #599.