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 tty: duplicate key with alt modifier #2111

Closed
parkovski opened this issue Dec 11, 2018 · 1 comment
Closed

Windows tty: duplicate key with alt modifier #2111

parkovski opened this issue Dec 11, 2018 · 1 comment
Labels

Comments

@parkovski
Copy link

  • Version: Latest neovim / node
  • Platform: Win10, 18298

When pressing a key combo with alt, the non-alt key is duplicated. Because of some quirks in the way event messages are generated, this only appears when using libuv under a ConPTY. Probably the easiest way to see this is to start a Windows exe in tmux in WSL. I see the problem both in neovim and nodejs.

Here is a nodejs program that demonstrates the issue:

process.stdin.setEncoding('utf8');
process.stdin.setRawMode(true);

process.stdin.on('data', x => {
  // Ctrl-C to quit
  if (x[0] == '\u0003') { process.exit(0); }
  console.log(x.length, x);
});

process.stdin.resume();

In a regular Windows console, or in a Linux terminal with or without a PTY, pressing for example, Alt+a will show 2 '\u001ba'. In a ConPTY however, it shows 3 '\u001baa'. This affects neovim, where a <M-*> keybinding also duplicates the key, breaking these bindings.

More info is here, including a screenshot of the difference in generated console events and the place in libuv where I think the problem is.

This C++ program will print all the generated console events, if it helps. Compile with C++17 (cl /EHsc /std:c++17 console.cpp).

@refack refack added the windows label Dec 11, 2018
bzoz added a commit to JaneaSystems/libuv that referenced this issue Dec 12, 2018
When releasing key with Alt pressed, the reported event has
LEFT_ALT_PRESSED state flag set. This confuses libuv, making it think
that Alt+numpad combination is used. This fixes this issue by removing
the check for state flag. Checking if VirtuakKeyCode is set to VK_MENU
is enough to detect the Alt+numpad case.

Fixes: libuv#2111
@bzoz
Copy link
Member

bzoz commented Dec 12, 2018

Thanks for the report. The line you suspected was to blame, fix for the issue is in #2114

@bzoz bzoz closed this as completed in d2e59bb Jan 3, 2019
njlr pushed a commit to buckaroo-pm/libuv that referenced this issue Apr 5, 2019
When releasing key with Alt pressed, the reported event has
LEFT_ALT_PRESSED state flag set. This confuses libuv, making it think
that Alt+numpad combination is used. This fixes this issue by removing
the check for state flag. Checking if VirtuakKeyCode is set to VK_MENU
is enough to detect the Alt+numpad case.

Fixes: libuv#2111
PR-URL: libuv#2114
Reviewed-By: Refael Ackermann <refack@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants