-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Bug Report: Control+Space not sent to terminal emulator. #2865
Comments
I'm going to guess this is a combo of:
There might be some discussion here if conpty should interpret a single NUL byte as Ctrl+Space. Isn't Ctrl+@ also NUL though? There might just be no way to handle that, if we can't be sure what it was to begin with. |
So I tested the following terminals:
And all of them interpret Ctrl+Space as NUL character. After long digging I finally found where I was first reading about it.
(Reference: Wikipedia) In the VT520 docs I sadly didn't find it with crossreading, but in VT220 docs (link found via Chapter 3.2.5) it looks like it is what I was looking for - even though it's not talking about Ctrl+@. But in case of doubt, I'd go with what most (see list above) terminal emulators do. Mapping Ctrl+Space to emit a NUL byte. :) EDIT: added OS/X terminal to the list. |
Ah but see the trick isn't in the Ctrl+Space -> NUL conversion. That's easy. The problem comes from conpty - the layer that's responsible for translating *nix-isms from the terminal into Windows-isms. We need to be able to build an I guess we could just presume one of them, with a note that it's by design, and hope for more robust input encoding to be able to support the other keystroke. |
Hey @zadjii-msft, thx for the quick response. I am not a Windows-isms-dev, so I can't talk much about Windows internals, but how I'd see that, is, that Ctrl+space, A..Z, [, , ], ^, _ is being translated to C0 control codes. I'm not sure you can simply construct an typedef struct _KEY_EVENT_RECORD {
BOOL bKeyDown;
WORD wRepeatCount;
WORD wVirtualKeyCode;
WORD wVirtualScanCode;
union {
WCHAR UnicodeChar;
CHAR AsciiChar;
} uChar;
DWORD dwControlKeyState;
} KEY_EVENT_RECORD; Maybe
WRT that, I don't think you really have to (from a console application's point of view, as - on the above terminal emulators, you can't either). What part could I be missing? |
So you're definitely on the right track here, but I'll point you straight at the meat of the code we're talking about: https://github.com/microsoft/terminal/blob/master/src/terminal/parser/InputStateMachineEngine.cpp The InputStateMachineEngine is the part of conpty that's responsible for translating a stream of characters into a stream of INPUT_RECORDs. You can see here us attempting to manually translate a bunch of other control keys already. Or here, where we're building the INPUT_RECORDs. We absolutely could use the So we can do this translation, and we can just pick one of Ctrl+Space or Ctrl+@ to be the translation for NUL, but we'd have to document it as such, because Windows client applications would no longer be able to differentiate between the two when running in conpty. I suppose that's not such a big deal, considering that neither works at all right now, but we'd still have to document it clearly, otherwise we'd inevitably get bug reports that say "when I press Ctrl+@ in the Terminal powershell thinks I pressed Ctrl+Space". |
Thanks for the detailed explanation. I keep forgetting it's Windows OS, nah. When it comes to documentation, I'd go with what most common terminal emulators to at the time of this writing (I try hard being objectively here :-D). But OTOH, I think maybe the #1173 could probably mitigate this issue? |
You're definitely right. #1173 will also apply to input to the client application, as well as output. |
Is this why ctrl-6 doesn't currently get passed through/interpreted properly? ctrl-any number seems to not be handled as expected at the moment |
Oh hey, did this get solved long before 1.1? I'm testing out a bunch of the #4999 scenarios right now, and this one just so happens to already work fine in the 0.11.1333 build of the Terminal I'm running. It's hard to know for sure, but I think we did something a while back that improved out NUL handling. |
Similar to this #2865 (comment) ;; TODO: remove this hack when bug fixed: https://github.com/PowerShell/Win32-OpenSSH/issues/1842
;; Add this to your Windows Terminal settings.json
;; {
;; "command":
;; { "action": "sendInput",
;; "input": "\u001b[9~"
;; },
;; "keys": "ctrl+space"
;; }
(global-set-key "\e[9~" 'set-mark-command) And if you use scree on the other side then you only need this in your .screenrc:
|
I had same issue in my development environment. |
To fix this, you can install this fixed version of the PowerShell openssh-portable project: PowerShell/openssh-portable#569 (comment) I just did so with |
Using Cygwin zsh inside Windows Terminal 1.13.11431.0, Ctrl+Space seems to do nothing, while it shoud do
so I can do Ctrl+Space to start selection, move the cursor, Ctrl+W ⇒ cut, move the cursor, Ctrl+Y ⇒ paste. Will that be addressed in #1173 (which is much too technical for me)? |
Thanks. I don't know how to report that to the Cygwin devs, though, since Cygwin zsh inside Cygwin mintty works. I'll just live with this workaround: (Found by pressing Ctrl+V, Ctrl+Del, which prints |
If anyone still facing this issue: This issue seems to be on
The ssh.exe client from windows does not handle CTRL+Space as the way it should be (atleast as of the latest windows today). Remember to use |
@thammegowda Oh, and in case you ask, I can't run ssh within WSL because for some reason it times out trying to connect to the host. Which is in a Hyper-V VM on the same machine. |
@michael-ts I run ssh inside WSL (first, Looks like you have issue with networking setup inside WSL, and your ssh is unable to reach to the remote. Verify that internet works inside WSL by |
@thammegowda Thanks, I can ping the Internet from WSL, but I have had no end to the networking issues with Hyper-V. I used to be able to ssh to it but had more serious issues, namely that networking would completely stop working outside of between the host and the VM at odd intervals. The fix for that apparently which I no longer recall caused this issue. Trying to administer my own machine is too much work sometimes... ;-) |
@michael-ts I think the solution is that somebody has to patch the OpenSSH inside windows dir ( |
@DHowett Thanks! I went searching for that and discovered I could update to that version from PowerShell using |
For anyone which doesn't have admin rights, you guys can use scoop to install the latest verison of
|
This doesn't appear to be fixed for me, even in a local WSL Ubuntu instance. I am running Terminal version |
Windows 11, Terminal 1.17.11461, powershell 7.3.4. ctrl-space isn't working in neovimj (no keycode sent after ctrl-q) |
Yeah tried setting up my Tmux config on WSL2 and can't get Ctrl+Space prefix key to work
Windows Terminal Preview 1.18.1462.0 |
Same. Regular WSL2 distro running bash inside Windows Terminal Preview Version: 1.18.1462.0.
Control + Space doesn't make it to the Linux shell. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Checking again, there seems to have been a bump to Windows, but nothing else:
Windows Terminal also seems to be the same version:
However now Control + Space reports as ^@:
That's fine for me, but a little weird that this started working without any apparent change to the system. Edit: Just to note I use a United Kingdom QWERTY layout, so I have a single quote/@ key instead of the US ANSI single/double quote key. I'm not sure how the keys map there. |
Environment
Steps to reproduce
Best way to see this (if you don't have key tracing on in our own terminal app),
fire up a TMUX session, have it configured with at least one more line, like this:
which basically states, that Ctrl+Space will cause the terminal to switch to the next window.
Except, that on Windows Terminal (or my terminal emulator, using ConPTY), it doesn't. :-)
Expected behavior
TMUX windows switching (i.e.: NUL-byte sent to PTY slave)
Actual behavior
Action Ignored.
The text was updated successfully, but these errors were encountered: