Skip to content

HotKeyGesture: treat modifier virtual keys explicitly, remove Windows modifier, and add display tests - #12

Open
stuartd wants to merge 2 commits into
mainfrom
codex/fix-hotkeymodifiers-windows-flag-behavior
Open

stuartd wants to merge 2 commits into
mainfrom
codex/fix-hotkeymodifiers-windows-flag-behavior

Conversation

@stuartd

@stuartd stuartd commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Improve validation of hotkey gestures by treating physical modifier virtual-key codes explicitly and disallowing modifier keys as primary keys.

Description

  • Removed the Windows flag from the HotKeyModifiers enum and replaced numeric VK literals with named constants like VirtualKeyShift, VirtualKeyControl, and VirtualKeyMenu plus left/right variants.
  • Centralized modifier virtual-key detection into a ModifierVirtualKeys set and updated IsValid to reject modifier VKs and reserved Windows keys (VirtualKeyLeftWindows/VirtualKeyRightWindows) as primary keys.
  • Simplified DisplayText by relying on IsValid for unassigned detection.
  • Updated tests to account for the removed enum member by using a raw value for the Windows modifier and added InvalidShortcutsDisplayAsUnassigned to assert invalid gestures render as Unassigned.

Testing

  • Ran the HotKeyGestureTests unit tests under tests/ClipDiff.Windows.Tests, which include DefaultShortcutIsCtrlAltD, FormatsTopRowNumpadAndFunctionKeys, RejectsUnsafeOrIncompleteShortcuts, InvalidShortcutsDisplayAsUnassigned, and InvalidPersistedShortcutFallsBackToDefault, and all tests passed.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant