Repository navigation
fix(shortcuts): recover modifier combos from missed key releases - #138
Merged
Merged
Conversation
A modifier could stay in pressedModifiers after it was released: right Shift let go while left Shift kept .shift set read as a press, and a lost key-up was never noticed. Every later combo then counted an extra modifier and the trigger check never ran until that key was pressed again. Each flagsChanged event carries the full modifier state, so drop tracked modifiers it reports as up, treat a repeated press as a missed release, and reset the hold cycle when nothing is left pressed.
This was referenced Sep 21, 2026
|
@runjuu Please make a new release, as this is an important fix. |
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.
Purpose
Modifier-combination shortcuts (e.g. Left Shift + Left Command) can stop working until the app restarts (#133).
ShortcutTriggerManagercould keep a modifier inpressedModifiersafter it was released. After that, every attempt counts as having an extra modifier, and the "all keys released" trigger check never runs.Two ways to get there:
.shiftflag set, so the release reads as a press.Closes #133
Changes
handleFlagsChangednow callsforgetMissedReleasesbefore handling an event. Each flagsChanged event carries the full modifier state, so it:handleFlagsChangedis now internal so tests can feed it events.Testing
ModifierComboTriggerTests(9 tests) driveShortcutTriggerManagerwith synthetic flagsChanged events. The 6 missed-release scenarios fail onmainand pass with this change: Right Shift / Right Command released while the left one is held, a lost Control release, a lost release of a combo key with either key pressed first, other combos (Right Option + Right Command, Left Control, a three-key combo), and Press Twice. The 3 tests covering existing behavior pass on both.xcodebuild -scheme "Input Source Pro" -configuration Debug test, 105 tests, 0 failures (Xcode 27.0, macOS 27.0).Notes
ShortcutTriggerManager.deinithandsselfto aTask, which traps once the object is freed ("deallocated with non-zero retain count"; Xcode warns about it too). The app never frees the manager, so users aren't affected, but tests would crash, so the test helper keeps its managers alive. Happy to send a separate fix.