Repository: microsoft/terminal (language: cpp)

Issue:
Dead keys + space bar not working through ssh or in wsl 2
### Windows Terminal version

1.20.10303.0

### Windows build number

10.0.22631.0

### Other Software

Bash, either in WSL 2 or through SSH on debian-based OS's (tested on Debian, Ubuntu and RasberryPi OS Bookworm)

### Steps to reproduce

* Use a keyboard layout that uses dead keys (e.g. US International)
* Press a "dead key" (e.g. `'`)
* Press the space bar

### Expected Behavior

The corresponding character to appear (e.g. an apostrophe)

### Actual Behavior

Only a space character appears.


Discussion / hints:
I think this may be related to #16641 
@Meryl Yeah, sorry about this. It's the same underlying cause.

Fix patch:
diff --git a/src/terminal/input/terminalInput.cpp b/src/terminal/input/terminalInput.cpp
index bdd10ca8d63..a8fd364e2ed 100644
--- a/src/terminal/input/terminalInput.cpp
+++ b/src/terminal/input/terminalInput.cpp
@@ -230,8 +230,12 @@ TerminalInput::OutputType TerminalInput::HandleKey(const INPUT_RECORD& event)
         return keyMatch->second;
     }
 
-    // If it's not in the key map, we'll use the UnicodeChar, if provided.
-    if (unicodeChar != 0)
+    // If it's not in the key map, we'll use the UnicodeChar, if provided,
+    // except in the case of Ctrl+Space, which is often mapped incorrectly as
+    // a space character when it's expected to be mapped to NUL. We need to
+    // let that fall through to the standard mapping algorithm below.
+    const auto ctrlSpaceKey = ctrlIsReallyPressed && virtualKeyCode == VK_SPACE;
+    if (unicodeChar != 0 && !ctrlSpaceKey)
     {
         // In the case of an AltGr key, we may still need to apply a Ctrl
         // modifier to the char, either because both Ctrl keys were pressed,
@@ -389,13 +393,6 @@ try
     defineKeyWithAltModifier(Ctrl + Enhanced + VK_RETURN, L"\n"s);
     defineKeyWithAltModifier(Ctrl + Shift + Enhanced + VK_RETURN, L"\n"s);
 
-    // SPACE maps to SP, and Ctrl+SPACE to NUL. The Shift modifier as no effect.
-    // The Alt modifier adds an ESC prefix (not standard).
-    defineKeyWithAltModifier(VK_SPACE, L" "s);
-    defineKeyWithAltModifier(Shift + VK_SPACE, L" "s);
-    defineKeyWithAltModifier(Ctrl + VK_SPACE, L"\0"s);
-    defineKeyWithAltModifier(Ctrl + Shift + VK_SPACE, L"\0"s);
-
     if (_inputMode.test(Mode::Ansi))
     {
         // F1 to F4 map to the VT keypad function keys, which are SS3 sequences.
@@ -581,6 +578,10 @@ wchar_t TerminalInput::_makeCtrlChar(const wchar_t ch)
     {
         return ch & 0b11111;
     }
+    if (ch == L' ')
+    {
+        return 0x00;
+    }
     if (ch == L'/')
     {
         return 0x1F;


Test patch: