fix(super_hot_key): use KeyboardKey instead of PhysicalKeyboardKey#561
Open
MSOB7YY wants to merge 6 commits into
Open
fix(super_hot_key): use KeyboardKey instead of PhysicalKeyboardKey#561MSOB7YY wants to merge 6 commits into
KeyboardKey instead of PhysicalKeyboardKey#561MSOB7YY wants to merge 6 commits into
Conversation
| }); | ||
|
|
||
| final PhysicalKeyboardKey key; | ||
| final KeyboardKey key; |
There was a problem hiding this comment.
Bug: Creating a hotkey with a non-printable LogicalKeyboardKey (e.g., arrow keys) will silently fail and return null because the underlying key map is incomplete.
Severity: MEDIUM
Suggested Fix
Instead of silently returning null for unsupported LogicalKeyboardKeys, the create method should validate the key and throw an informative exception if it's not supported. Alternatively, fully implement support for all LogicalKeyboardKey types in the native code by correctly mapping non-printable keys.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: super_hot_key/lib/super_hot_key.dart#L16
Potential issue: The change from `PhysicalKeyboardKey` to `KeyboardKey` in
`HotKeyDefinition.key` implies full support for `LogicalKeyboardKey`. However, the
underlying implementation only maps logical keys for printable characters. When
attempting to register a hotkey with a non-printable `LogicalKeyboardKey` (e.g.,
`LogicalKeyboardKey.arrowLeft`, function keys), the lookup in the internal
`_logicalToKey` map fails. This causes `getPlatformKeyCode` and subsequently
`HotKey.create()` to return `null` without any warning or exception. This silent failure
can be difficult to debug as developers might assume the hotkey was registered
successfully.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
for some reason, the
HotKeyDefinitionusesPhysicalKeyboardKeyinstead ofKeyboardKey(super_native_extensions/super_hot_key/lib/super_hot_key.dart
Line 16 in ca42ab7
even tho the internal implementation supports
KeyboardKey:super_native_extensions/super_native_extensions/lib/src/keyboard_layout.dart
Lines 32 to 40 in ca42ab7
not sure why it wasn't like that, most likely a typo