Skip to content

Commit

Permalink
Fix Control+Space not sent to program running in terminal (microsoft#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnywong committed Nov 12, 2023
1 parent d14524c commit 2e2b53c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/host/inputBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,9 @@ void InputBuffer::_HandleTerminalInputCallback(const TerminalInput::StringType&

for (const auto& wch : text)
{
_storage.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, 0));
// We can't get a null byte without the control key. Can we?
uint32_t dwControlKeyState = (wch == 0) ? CTRL_PRESSED : 0;
_storage.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, dwControlKeyState));
}

if (!_vtInputShouldSuppress)
Expand Down
9 changes: 5 additions & 4 deletions src/host/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,11 @@ static bool IsCommandLineEditingKey(const KEY_EVENT_RECORD& event)

const auto zeroKey = OneCoreSafeVkKeyScanW(0);

if (LOBYTE(zeroKey) == Event.Event.KeyEvent.wVirtualKeyCode &&
WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, ALT_PRESSED) == WI_IsFlagSet(zeroKey, 0x400) &&
WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, CTRL_PRESSED) == WI_IsFlagSet(zeroKey, 0x200) &&
WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, SHIFT_PRESSED) == WI_IsFlagSet(zeroKey, 0x100))
if ((LOBYTE(zeroKey) == Event.Event.KeyEvent.wVirtualKeyCode &&
WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, ALT_PRESSED) == WI_IsFlagSet(zeroKey, 0x400) &&
WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, CTRL_PRESSED) == WI_IsFlagSet(zeroKey, 0x200) &&
WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, SHIFT_PRESSED) == WI_IsFlagSet(zeroKey, 0x100)) ||
(Event.Event.KeyEvent.wVirtualKeyCode == 0 && WI_IsAnyFlagSet(Event.Event.KeyEvent.dwControlKeyState, CTRL_PRESSED)))
{
// This really is the character 0x0000
*pwchOut = Event.Event.KeyEvent.uChar.UnicodeChar;
Expand Down

0 comments on commit 2e2b53c

Please sign in to comment.