Refactor: extract key-capture accept/translate rules into KeyCaptureRules#11
Merged
Merged
Conversation
…ules ShortcutCapture (global hotkeys) and EditorKeyCapture (editor tool rebinding) embedded their pure accept/translate decisions inside NSEvent monitor closures, where they couldn't be tested. Lift them out: - HotKeyCaptureRule.combination(keyCode:modifiers:) — requires >=1 device- independent modifier, else nil. - EditorToolKey.binding(char:modifiers:) — lowercases, validates the char set, prefixes the Shift glyph only when Shift alone is held. The single-flight monitor mechanism (which is NSEvent-coupled) stays in place; only the testable rules move. Behavior-preserving. Adds KeyCaptureRulesTests (10 cases).
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
…ules (#11) Lift the pure accept/translate decisions out of ShortcutCapture and EditorKeyCapture's NSEvent monitor closures into HotKeyCaptureRule.combination( keyCode:modifiers:) and EditorToolKey.binding(char:modifiers:). The NSEvent- coupled single-flight mechanism stays in place. Behavior-preserving. Adds KeyCaptureRulesTests (10 cases). CI green.
GamalAnwar
added a commit
that referenced
this pull request
Jun 18, 2026
…ules (#11) Lift the pure accept/translate decisions out of ShortcutCapture and EditorKeyCapture's NSEvent monitor closures into HotKeyCaptureRule.combination( keyCode:modifiers:) and EditorToolKey.binding(char:modifiers:). The NSEvent- coupled single-flight mechanism stays in place. Behavior-preserving. Adds KeyCaptureRulesTests (10 cases). CI green.
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.
Summary
Slice 2 of 2. Both single-flight key captures —
ShortcutCapture(global hotkeys) andEditorKeyCapture(editor tool rebinding) — embedded their pure accept/translate decisions inside theNSEventmonitor closures, where they were untestable. This lifts the decisions out:The monitor closures now read as control-flow only:
Scope / safety
mods == .shiftexact-match for the ⇧ prefix, same.deviceIndependentFlagsMaskintersection.static active,cancelActive, monitor add/remove, Esc-cancel,flagsChangedignore) is deliberately left in place — it's inherentlyNSEvent-coupled and not unit-testable. Only the pure rules moved.Tests
KeyCaptureRulesTests(10 cases): plain letter, lowercasing, ⇧-prefix on Shift, no prefix for Command, Shift+other not treated as Shift, valid symbol/digit, empty/space rejected; and for hotkeys: modifier required, keyCode+modifiers preserved, non-device-independent bits stripped.Note
This is independent of #10 (thumbnail geometry) — different files, both branched off
master. They can merge in any order.🤖 Generated with Claude Code
Generated by Claude Code