-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Readline keypress event is triggered only after pressing Esc key 3 times #7379
Comments
Didn't need the readline interface. It's now a lot faster too. Added some keyboard shortcuts. Escape bug is still there, but now reported: nodejs/node#7379
I've dug into this a bit and can confirm the bug exists in It would appear to have been introduced in |
So it would appear that escape started acting weird after aed6bce906 landed. Doesn't appear to be easily revertable... I'm digging into what is going on with escape |
Found the offending section https://github.com/nodejs/node/blob/master/lib/internal/readline.js#L144-L151 The original PR introduced this logic which yields to more results if the first character is an escape... which is problematic if your entire payload is an escape. It allows for double escaped characters, which is why things work on the third press Not sure the best way to approach this, but I'll revisit in the morning |
@thealphanerd It was mentioned in the PR itself. |
@princejwesley sigh... I wish I had read the pr instead of just the commit and then digging into the code. @cjihrig you have the blame on most of |
@thealphanerd I'll fix it! |
Sorry I'm late to this party. It looks like a proposed fix is available. But for the record, I don't think this is a |
@cjihrig I accepted that drawback as the primary use of esc in a terminal is to start an escape sequence, but I now see the issue with applications relying on that key. @princejwesley I guess a timeout-based approach to triggering the key is the way to go. I just don't know if 700ms is the correct value, seems a tad high. |
@silverwind |
How about 500ms, like in GNU readline (http://man7.org/linux/man-pages/man3/readline.3.html)? |
@silverwind Done |
This has been backported to v4.x in 68a2979 |
Test case
Expected
After pressing Esc once, I would get this output:
Actual
After pressing Esc three times, I get this output:
It works fine on 0.10.44 and 0.12.13. After pressing Esc once:
Also notice that
meta
isfalse
here.The text was updated successfully, but these errors were encountered: