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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/terminal/input/terminalInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 == keyEvent.GetVirtualKeyCode();

// Only need to handle key down. See raw key handler (see RawReadWaitRoutine in stream.cpp)
if (!keyEvent.IsKeyDown())
{
// If this is a release of the last recorded key press, we can reset that.
if (keyEvent.GetVirtualKeyCode() == _lastVirtualKeyCode)
if (matchingLastKeyPress)
{
_lastVirtualKeyCode = 0;
_lastVirtualKeyCode = std::nullopt;
}
return false;
}

// If this is a repeat of the last recorded key press, and Auto Repeat Mode
// is disabled, then we should suppress this event.
if (keyEvent.GetVirtualKeyCode() == _lastVirtualKeyCode && !_inputMode.test(Mode::AutoRepeat))
if (matchingLastKeyPress && !_inputMode.test(Mode::AutoRepeat))
{
// Note that we must return true here to say we've handled the event,
// otherwise the key press can still end up being submitted.
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/input/terminalInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace Microsoft::Console::VirtualTerminal
// storage location for the leading surrogate of a utf-16 surrogate pair
std::optional<wchar_t> _leadingSurrogate;

WORD _lastVirtualKeyCode{ 0 };
std::optional<WORD> _lastVirtualKeyCode;

til::enumset<Mode> _inputMode{ Mode::Ansi, Mode::AutoRepeat };
bool _forceDisableWin32InputMode{ false };
Expand Down