Problem after removing keybinding for bind -m vi-insert '"jj": "\e\e"'

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem after removing keybinding for bind -m vi-insert '"jj": "\e\e"'

Clark WANG-2
[STEP 100] # echo $BASH_VERSION
4.4.12(4)-release
[STEP 101] # bind -m vi-insert '"jj": "\e\e"'
[STEP 102] # bind -X
"jj": "\e\e"
[STEP 103] # bind -r jj
[STEP 104] # bind -X
[STEP 105] #     <-- Here when I press j it still waits for about 1 second
to show up.
Reply | Threaded
Open this post in threaded view
|

Re: Problem after removing keybinding for bind -m vi-insert '"jj": "\e\e"'

Chet Ramey
On 11/20/17 11:25 PM, Clark Wang wrote:

> [STEP 100] # echo $BASH_VERSION
> 4.4.12(4)-release
> [STEP 101] # bind -m vi-insert '"jj": "\e\e"'
> [STEP 102] # bind -X
> "jj": "\e\e"
> [STEP 103] # bind -r jj
> [STEP 104] # bind -X
> [STEP 105] #     <-- Here when I press j it still waits for about 1 second
> to show up.
>

Here's what happens: when you bind "jj", it creates a new keymap to handle
the longer key sequence, and notes that `j' is now ambiguous: it's either
`jj' or `j' when followed by any other character. That's the reason for the
delay.

Removing the binding leaves the new keymap in place, because readline
doesn't check whether removing that binding results in an empty keymap,
which would remove the ambiguity.

Readline doesn't have the internal machinery in place to check for and
remove empty keymaps when removing a key binding. I'll have to look at
what it will take to add.

Chet


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [hidden email]    http://cnswww.cns.cwru.edu/~chet/