fix(settings): reserve every hardcoded menu shortcut against user rebinding - #2459
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Two defects found while investigating #2453, both in the same class: a hand-maintained list that has to agree with something else, and nothing forcing it to.
You can silently kill Quit
reservedAppShortcutsheld only Zoom In, Zoom Out andCmd+1throughCmd+9. Seven other combos are hardcoded by the menu builders and belong to noShortcutAction, so the recorder had nothing to refuse them with:Cmd+QCmd+MCmd+HCmd+Option+HCmd+,Cmd+Option+TCtrl+Cmd+FReproduction: Settings > Keyboard, bind Toggle Filters to
Cmd+Q. All three resolver gates pass, the binding is stored, andMainMenuKeyEquivalentSyncputsCmd+Qon Show Filter Bar. Two menu items now claim it and AppKit blanks one.SystemHotkeyCheckerdoes not catch these, becauseCopySymbolicHotKeysreports system-wide hotkeys, not per-app menu standards.Ctrl+Cmd+Jwas missing fromeditorBuiltInseditorBuiltInsis a hand-maintained mirror of the vendored fork's key-binding switch, and it had drifted:TextViewController+Lifecycle.swift:277handles[command, control], "j"for Jump to Definition, with no matching entry. Bind an editor or global action toCtrl+Cmd+Jand the recorder accepts it, then the fork's local monitor claims the keystroke first and the binding never fires.The guard
Both lists are hand-maintained, so a fix that only adds today's missing entries buys nothing against tomorrow's.
hardcodedKeyEquivalentsAreReservedbuilds the real menu, subtracts every combo anyShortcutActionresolves to, and asserts the remainder is reserved. A hardcoded item added later without areservedAppShortcutsentry now fails the build.It carries an explicit non-vacuity assertion, which earned its place: two earlier drafts of this test passed while checking nothing. The first keyed off
NSMenuItem.identifier == nilto spot hardcoded items, but AppKit synthesizes identifiers, so the filter matched zero items. The second usedBoundKey.character(_:), which callsassertionFailurefor any character with no key code on the active layout, and menu items carry arrow and escape key equivalents, so it crashed the whole suite. The shipped version compares canonicalmodifiers-characterstrings and never constructs aBoundKeyfrom menu data.Verification
verify.sh buildverify.sh test(14 menu + keyboard suites)verify.sh lint TablePro TableProTestsBoth entries are in a shipped build, so both get a CHANGELOG line.