fish-shell / fish-shell Public
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
Esc + H in Vi mode opens manpage causing undesirable functionality #3904
Comments
The issue here is that opening the man page is bound to "\eh", which is meant to be alt+h, but because of the way terminals work will also be triggered by escape+h. vi-mode obviously also has a binding for escape by itself (switching modes). The way we figure out whether you pressed escape, then pressed "h" or pressed alt+h is waiting for a certain timeout between the keys. This is set to 100ms by default (in vi-mode, in emacs-mode it's set to 300ms), so you'll need to wait for that amount of time before pressing another key if the corresponding sequence is also bound. This timeout can be configured through the "fish_escape_delay_ms" variable. E.g. Alternatively, you could remove the \eh binding - add @krader1961: I've noticed when running Maybe our timeout is still too long? 10ms still seems like it'd leave an order of magnitude of slack for slow machines? |
@faho: The problem with 10ms is that is is too short except for extremely fast typists. Too, that was the original value which was causing problems which is why we increased it. A value of 100ms may be too long for moderately fast typists. I wouldn't be surprised if we conducted actual HCI (human computer interaction) tests that we would find a value in the range of 20 to 30ms to be optimal. Someone with some strong google-fu may be able to find such studies or documents describing the optimal value. Alternatively, simply figuring out how Vim handles this might be instructive. |
Also, the delay isn't for the meta-key case. Except for extreme situations such as running fish inside tmux on both the client and server system over generally slow connections (e.g., dialup) with extreme latency variability it is unlikely the escape and subsequent characters will ever be received with more than a millisecond between them. |
@faho Thank you very much, that's exactly what I was looking for just a simple workaround will do. Optimally this binding could change depending on if the user is in vi_mode or not. I tested Bash and Zsh and did some research to see if they bind to another key, but it didn't work in my other shells and these pages seem to indicate it's not default in Bash or Zsh either. The default behavior seems to be a useful feature if the user is not using vi mode though. |
The issue there is if we remove it, we'll just get users asking to add it back. What we've come up with is that emacs-mode and vi-mode should share all bindings that don't specifically relate to "editing text" (i.e. moving the cursor or inserting/removing characters). It's also not specific to this binding - anything bound to alt+something will have this issue, as will most "special" keys (you know, unusual stuff like the arrow keys). So: No, we will not remove it. Now, what we IMHO should do here is to make it harder to accidentally hit.
@krader1961: The way I see it, the usual way to execute a So the timeout in vi-mode should be purely for slow terminals, not slow users. That would be something like 10-20ms, not 100ms. Note: It's unfortunate that there's a need to choose here, but given that need, we should pick the usual case over the unusual one. |
Yes, @faho, but the reason we increased the delay is that someone pointed out that even a fast typist could not reliably perform sequences prefaced by an escape character when typing each character independently. And at least a few people felt it was reasonable to make it possible to invoke behaviors introduced by an escape character by typing each character, including the escape, one at a time. As opposed to something like pressing [alt-X] which would send It is extremely annoying that Bill Joy (the person who wrote the original vi editor) chose to use escape, character \x1B, rather than some other control character for the transition from insert to command mode. Especially since at that time the standard established by the DEC VT100 (now ANSI X3.64) to preface other magic sequences by the escape character was well known. @RomanSC: Can you explore various values for The problem here is that any non-zero delay is problematic given "vi"editor semantics for the escape character. |
@krader1961 If I could pipe the output of fish_key_reader -c into a text file for each terminal opened somehow then let it run for a while I could give you guys a case study for this after formatting the file to only contain:
( 32.653 ms) hex: 68 char: h Otherwise it seems for me that around 30 ms is good, but I think in that case @faho has a good point. Seems that would only be useful with more users' test cases, and especially those who use ssh/tmux etc. |
See also issue #3398. The $fish_escape_delay_ms value affects recognition of all multi-char sequences, not just those beginning with an escape character. Do the following:
Now type [ctrl-X][ctrl-E] with various delays between the two control characters. Then |
Also, I just ran |
Too, a fast typist (e.g., 60 words/minute) is still typing characters at a rate that has approximately 125 ms between characters. |
I'm also running into problems with getting into the man pages fairly frequently, 3-5 times a day. If I push the esc time down to 10ms, I then probably can't type "ESC+e" to get enhanced editing of commands, and "Alt+e" doesn't work for me (that seems to type an a with a halo). I do really like the suggestion features in fish, but it has been a hard transition from zsh as a vi user. |
@linsomniac, The reason [alt]+letter doesn't work is because your terminal is treating [alt] as a unicode compose key rather than a meta key that prefixes an escape char to the next key. That has nothing to do with fish and you'll see the same behavior with bash and zsh. If you're using iTerm2 open the terminal profile you're using, switch to the "Keys" tab and find the following settings: Other terminals have similar config options. |
Thanks. I did understand that it was my terminal, not fish. It's just that the issue is particularly bad for me and the person who opened this issue because ESC+h is something that is frequently typed as just a normal part of editing in vi mode. I ended up unbinding \eh in regular and insert modes and changed it instead to \eH |
Version: fish, version 2.5.0
OS: Arch Linux 4.10.3-1-ARCH
Terminal: Termite
So I ran fish vi mode in sh -c 'env HOME=$(mktemp -d) fish' and problem should be immediately reproducable. In the default env enable fish_vi_key_bindings, type out a command like 'sudo fun foo' then press Esc and H, but quickly. Fish will then open a manpage for sudo. The user must then press q, but all they are trying to do is press Esc to exit insert mode then H to move back characters as in normal vi/vim
Seems to be some kind of default binding as pressing Esc then H in non-vi mode also opens a manpage for the first typed command.
Is there a workaround?
Thanks for the awesome shell.
The text was updated successfully, but these errors were encountered: