From 8747a39a07dd601141a2ce2ee6eb076a8a5599b6 Mon Sep 17 00:00:00 2001 From: Lonny Wong Date: Tue, 28 Nov 2023 05:31:06 +0800 Subject: [PATCH] Fix Control+Space not sent to program running in terminal (#16298) Converts null byte to specific input event, so that it's properly delivered to the program running in the terminal. Closes #15939 --- src/host/inputBuffer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/host/inputBuffer.cpp b/src/host/inputBuffer.cpp index 5150a21427d..abdfed1961f 100644 --- a/src/host/inputBuffer.cpp +++ b/src/host/inputBuffer.cpp @@ -830,6 +830,17 @@ void InputBuffer::_HandleTerminalInputCallback(const TerminalInput::StringType& for (const auto& wch : text) { + if (wch == UNICODE_NULL) + { + // Convert null byte back to input event with proper control state + const auto zeroKey = OneCoreSafeVkKeyScanW(0); + uint32_t ctrlState = 0; + WI_SetFlagIf(ctrlState, SHIFT_PRESSED, WI_IsFlagSet(zeroKey, 0x100)); + WI_SetFlagIf(ctrlState, LEFT_CTRL_PRESSED, WI_IsFlagSet(zeroKey, 0x200)); + WI_SetFlagIf(ctrlState, LEFT_ALT_PRESSED, WI_IsFlagSet(zeroKey, 0x400)); + _storage.push_back(SynthesizeKeyEvent(true, 1, LOBYTE(zeroKey), 0, wch, ctrlState)); + continue; + } _storage.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, 0)); }