-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure VT reports still work when DECARM is disabled #14216
Conversation
src/terminal/input/terminalInput.cpp
Outdated
@@ -551,20 +551,23 @@ bool TerminalInput::HandleKey(const IInputEvent* const pInEvent) | |||
return true; | |||
} | |||
|
|||
// Check if this key matches the last recorded key code. | |||
const auto matchingLastKeyPress = _lastVirtualKeyCode && _lastVirtualKeyCode.value() == keyEvent.GetVirtualKeyCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cute std::optional
trick: you don't need to check whether the optional is populated before doing a comparison; nullopt == T{}
will always return false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, that's neat! Thank you!
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
The way
DECARM
was initially implemented, we checked for repeated keypresses by matching the last recorded virtual key code, and used a 0 key
code to indicate that no key was pressed. This caused the VT query
responses to fail, because they generated key events with a 0 key code,
and that would end up being detected as a repeated key that should be
suppressed.
This PR fixes that issue by using a
std::optional
to track the lastkey code, so if no key has been pressed we can represent that with
std::nullopt
, and there's no way that can be confused with a genuinekey press.
The
DECARM
mode was introduced in PR #13981.Validation Steps Performed
I've manually tested in Vttest to confirm that the query reports are now
working again, even when
DECARM
is disabled. I've also checked thatDECARM
itself it still working as expected.Closes #14208