microsoft / microsoft/terminal
Possible bug: Inconsistency between WM_KEYDOWN and WM_KEYUP
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
While investigating something related to control key events, I was looking at the source code to `TerminalContainer_MessageHook` in `TerminalContainer.cs` and saw this:
https://github.com/microsoft/terminal/blob/0f5d883c59201007e8a7cd4c576477d2b5157cf7/src/cascadia/WpfTerminalControl/TerminalContainer.cs#L349-L364
This has a "smell" to it: Both handler cases call `UnpackKeyMessage` populating a local variable `vkey`, but only one of them actually _uses_ it. The `WM_KEYDOWN` handler passes `vkey` on to `TerminalSendKeyEvent`, but the `WM_KEYUP` handler passes `wParam` unaltered for the same parameter.
Is this a bug?
If not, I would recommend calling out the difference between the two `TerminalSendKeyEvent` calls explicitly, with a comment or a strategically-named local variable or what have you.
Contributor guide
Research direction
Start in src/cascadia/WpfTerminalControl/TerminalContainer.cs at TerminalContainer_MessageHook, especially the WM_KEYDOWN and WM_KEYUP cases. Trace UnpackKeyMessage and both TerminalSendKeyEvent calls to determine whether the differing parameters are intentional. Done means confirming the behavior and either correcting the inconsistency or documenting the reason for it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100