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

Windows: console: <C-2>, <C-/> #8435

Open
parkovski opened this issue May 24, 2018 · 25 comments
Open

Windows: console: <C-2>, <C-/> #8435

parkovski opened this issue May 24, 2018 · 25 comments
Labels
platform:windows status:blocked-external Needs a third-party / external change or fix tui
Milestone

Comments

@parkovski
Copy link

A couple control key combos are missing on Windows, notably ^@ which prevents <C-space> mappings.

  • nvim --version: 0.2.2 (still present in 0.3)
  • Vim (version: 8.1) behaves differently? Yes
  • Operating system/version: Win10 17672
  • Terminal name/version: conhost
  • $TERM: N/A

Steps to reproduce using nvim -u NORC

Type the following keys in insert mode preceded by <C-v>: <C-2> <C-space> <C-/>

Actual behaviour

<C-2> and <C-/> are not recognized at all, <C-space> is recognized as regular space.

Expected behaviour

The control characters ^@^@^_ are inserted.

There is slightly different behavior between Windows vim and Linux vim/nvim here. On Windows vim, ^_ is not generated when pressing <C-/> (but it can be generated by the _ key still), and <C-space> does not generate ^@, it types a space, but <C-space> itself is mappable. Copying either behavior would probably be fine, although I'd prefer to mimic Linux as it leads to a less complicated vimrc.

@justinmk

This comment has been minimized.

@parkovski

This comment has been minimized.

@justinmk

This comment has been minimized.

@justinmk justinmk reopened this May 24, 2018
@justinmk justinmk added this to the todo milestone May 24, 2018
@justinmk justinmk changed the title Missing key combos on Windows Windows: console: <C-2>, <C-/> May 24, 2018
@justinmk
Copy link
Member

justinmk commented Sep 9, 2018

@parkovski I don't know any terminal where <C-/> does anything, in Vim or otherwise.

Based on libuv/libuv#1958 I guess the other cases are blocked by libuv.

@justinmk justinmk added the status:blocked-external Needs a third-party / external change or fix label Sep 9, 2018
@mqudsi
Copy link
Contributor

mqudsi commented Nov 1, 2018

Windows 10 added support for both mapping ctrl-space to ^@ and mapping ctrl-/ to ^_; they're at least in the latest official release (1809/17763) as tested with stock conhost.

@erw7
Copy link
Contributor

erw7 commented Feb 6, 2019

@mqudsi It probably will not make sense unless you are using WSL or by setting ENABLE_VIRTUAL_TERMINAL_INPUT and using ReadFile() or ReadConsole(). And libuv tty has not used it(ENABLE_VIRTUAL_TERMINAL_INPUT) yet.

@parkovski Please try the artifacts of #9094. It should correspond to everything to the libuv/libuv#1958 combo keys.

@mqudsi
Copy link
Contributor

mqudsi commented Feb 6, 2019

@erw7 Yes, this is under WSL, but they work even when SSH'd into Linux/macOS and running neovim there.

@erw7
Copy link
Contributor

erw7 commented Feb 6, 2019

This issue is about Windows native neovim. I do not want to talk about WSL here, because the talk becomes complicated.

@mqudsi
Copy link
Contributor

mqudsi commented Feb 6, 2019

Neovim can possibly call SetConsoleMode(..., GetConsoleMode(...) | ENABLE_VIRTUAL_TERMINAL_PROCESSING) itself.

@parkovski
Copy link
Author

@erw7 That build fixes all the issues except C-Space in a ConPTY (running vim.exe in a WSL tmux window). The ConPTY seems to generate C-Shift-2 (modifiers = Shift | LCtrl, vk = 0x32 '2', UnicodeChar = 0) which is not handled.

@erw7
Copy link
Contributor

erw7 commented Feb 25, 2019

@parkovski Sorry to reply late. Thank you for the information. The problem of when executing nvim in WSL can be easily coped with rebuilding libuv with the following patch applied.

diff --git a/src/win/tty.c b/src/win/tty.c
index c8e239c4..9d8ffdaf 100644
--- a/src/win/tty.c
+++ b/src/win/tty.c
@@ -710,7 +710,7 @@ static const char* get_vt100_fn_key(DWORD code, char shift, char ctrl,
     VK_CASE(VK_SPACE,     NULL,       NULL,        "\0",        NULL)  /* <C-Space> => ^@ */
     VK_CASE(0x30,         NULL,       NULL,        "0",         NULL)
     VK_CASE(0x31,         NULL,       NULL,        "1",         NULL)
-    VK_CASE(0x32,         NULL,       NULL,        "\0",        NULL)  /* <C-2> => ^@ */
+    VK_CASE(0x32,         NULL,       "\0",        "\0",        NULL)  /* <C-2> => ^@ */
     VK_CASE(0x33,         NULL,       NULL,        "3",         NULL)
     VK_CASE(0x34,         NULL,       NULL,        "4",         NULL)
     VK_CASE(0x35,         NULL,       NULL,        "5",         NULL)

The comment of input.c in the xterm source code lists several other mappings (contol 3 0x1b, etc). I would like to decide what to do with them together with the problems of this #9094 (comment). So please wait for a while to change #9094?

@parkovski
Copy link
Author

I've been using this libuv patch for a while, and have not had any issues with windows keys since.

@icy-comet

This comment was marked as off-topic.

@georgejean

This comment was marked as off-topic.

@justinmk
Copy link
Member

Can you try the development version?

  • The Releases page has pre-built archives for Windows.
  • Check :version to confirm that you are using the latest version.

@mqudsi
Copy link
Contributor

mqudsi commented May 16, 2022

The code from nvim v0.8.0-dev+226-g07ade91f2 running under conhost.exe (not from Windows Terminal.app) under WSLv1 on Windows 10 1909 has the following mapping:

  • Ctrl-space: <C-Space>
  • Ctrl-2: <C-Space>
  • Ctrl-/: ^_

If nvim v0.8.0-dev+221-ge501e4ed4 is used as a Windows-native binary (again, started with the system conhost.exe), the following mapping is observed:

  • Ctrl-space: no input/not seen
  • Ctrl-2: no input/not seen
  • Ctrl-/: ^_

So the behavior has changed from the initial report, but is still not where it needs to be. The fact that ctrl-space and ctrl-2 generate no input at all is a step in the right direction, as it means they just need new mappings in the event loop rather than changing an existing, incorrect mapping (going off the fact that they were seen but just processed incorrectly before, so it's not like they're not detectable). The behavior of ctrl-/ seems fine/correct.

@justinmk
Copy link
Member

justinmk commented Dec 11, 2022

Current status is described in #8435 (comment) . Please avoid "me too" comments (upvote the issue instead). Send a PR if you have a fix.

@GitMurf

This comment was marked as duplicate.

@GitMurf
Copy link

GitMurf commented Jan 20, 2024

FYI for those who stumble across this, this was a "bug" in Microsoft Windows Terminal and all the details can be found here: microsoft/terminal#15939

Here is the PR with the fix which has not landed in the core terminal release yet on Windows: microsoft/terminal#16298

@AxiomOfChoices
Copy link

@GitMurf The bug isn't solely responsible for this, I get this issue without using Microsoft Windows Terminal (I use Wezterm).

@kulkalkul

This comment was marked as outdated.

@MarcoBuess
Copy link

MarcoBuess commented May 16, 2024

Latest version of Windows Terminal (v1.20.11271.0) also introduced a situation where <C-^> was not working as expected anymore. I was able to fix that defining a custom action in the WT config:

    "actions": [
        {
            "command": {
                "action": "sendInput",
                "input": "\u001e"
            },
            "keys": "ctrl+^"
        }
    ],

Cloud this be a viable workaround for <C-Space> and <C-BS> as well? Which unicode would be expected?

Edit: So I tried sending \u0000 which didn't do anything. 😞

@kulkalkul
Copy link

@MarcoBuess and anyone experiencing the issue and wants a workaround, using PowerToys (https://learn.microsoft.com/en-us/windows/powertoys/) Keyboard Manager works. I mapped my nvim completion to <C-Y> and mapped keyboard manager from <C-Space> to <C-Y> for WindowsTerminal.exe. Though as a side effect, it requires other terminal related remapping of <C-Space>.

@IvanXh0
Copy link

IvanXh0 commented May 19, 2024

For anyone still struggling with this, this ended up working for me in enabling <C-Space> without any remaps inside the settings.json file:

{
            "keys": "ctrl+space",
            "command": {
                "action": "sendInput",
                "input": "\u001b[32;5u"
            }
        }
       

@MarcoBuess
Copy link

@IvanXh0 Are you running in WSL? I'm running outside WSL and the sequence yields " for me.

Silas-K added a commit to Silas-K/powershell-profile that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:windows status:blocked-external Needs a third-party / external change or fix tui
Projects
None yet
Development

No branches or pull requests