fix: ⌘ tap switches IME even while Shift/other modifiers are held (regression from 2.4.11)#126
Merged
Merged
Conversation
…trip residual flags from the synthesized tap Regression from the 2.4.11 chord-cancel (#122): holding Shift (or any other modifier) and tapping ⌘ no longer switched the input source, breaking "commit kana conversion with left ⌘". Three defects in the tap gesture path: - modifierKeyDown cancelled the lone-press gesture whenever a second modifier was physically held, so every Shift/Option/Control+⌘ tap was a no-op. Replaced the single tracked-keyCode slot + downModifierKeyCodes chord-cancel with per-modifier pending taps (`pendingModifierTaps`): a modifier release fires its mapping iff nothing but modifier activity happened since its own press, regardless of press/release order. This also removes the inconsistent re-arm hole #122 was closing — taps now fire consistently instead of never. - The synthesized Eisu/Kana event inherited residual held-modifier flags (convertedEvent keeps event.flags), so even when a tap fired with Shift held the IME saw Shift+英数 and ignored it. modifierKeyUp now posts the bare output shortcut (output keyCode + output flags only) through a postModifierTap seam (injectable for tests). - keyUp of a regular key unconditionally cancelled the pending gesture, so pressing ⌘ to commit while the last typed character key was still physically depressed (routine in fast typing) misfired. Only keyDown, mouse events, and media keys cancel now. Reworks the modifier-gesture unit tests around the new semantics and the capture seam: taps with Shift held (both orders), independent sibling taps, keyDown-cancel, keyUp-no-cancel, disable-mapping, and residual-flag stripping. Release 2.5.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
Since v2.4.11 (#122), tapping a Command key while any other modifier is held no longer switches the input source. Holding Shift and tapping left ⌘ — e.g. committing a kana conversion and dropping to eisu — does nothing.
Causes (three defects in the tap gesture path)
modifierKeyDowncancelled the lone-press gesture whenever a second modifier was physically held, making every Shift/Option/Control+⌘ tap a no-op.Fix
pendingModifierTaps) replace the single tracked-keyCode slot + chord-cancel: a modifier release fires its mapping iff nothing but modifier activity happened since its own press, regardless of press/release order. This intentionally supersedes fix(keyevent): tear down old event tap on rebuild, cancel lone-modifier gesture on chords, post keyUp for media-key remaps #122's semantics — taps fire consistently instead of never, which also removes the inconsistent re-arm hole fix(keyevent): tear down old event tap on rebuild, cancel lone-modifier gesture on chords, post keyUp for media-key remaps #122 was closing.modifierKeyUpposts the bare output shortcut (output keyCode + output flags only), stripping residual held-modifier flags, through apostModifierTapseam injectable in tests.Tests
swift test: 51 tests, 0 failures. New coverage: Shift-held taps (both press orders), residual-flag stripping, independent sibling-command taps, keyDown-cancel, keyUp-no-cancel, disable-mapping.Releases as 2.5.0 (manifest + CHANGELOG updated).
🤖 Generated with Claude Code