Skip to content
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

Merged
2 commits merged into from
Oct 14, 2022

Conversation

j4james
Copy link
Collaborator

@j4james j4james commented Oct 13, 2022

The way DECARM was initially implemented, we checked for repeated key
presses 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 last
key 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 genuine
key 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 that
DECARM itself it still working as expected.

Closes #14208

@ghost ghost added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Oct 13, 2022
@@ -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();
Copy link
Member

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

Copy link
Collaborator Author

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!

@j4james j4james marked this pull request as ready for review October 13, 2022 23:49
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 14, 2022
@ghost
Copy link

ghost commented Oct 14, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 0022898 into microsoft:main Oct 14, 2022
@j4james j4james deleted the fix-decarm-reports branch December 26, 2022 20:58
@ghost
Copy link

ghost commented Jan 24, 2023

🎉Windows Terminal Preview v1.17.1023 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal reports no longer work in Vttest
3 participants