Escape in vi mode to end paging, but stay in insert mode

Change the escape key binding in insert mode (in vi key bindings)
to check if we are in paging mode. If so, emit cancel and stay in
insert mode. Otherwise perform the current behavior of switching
back to default mode and adjusting the cursor.

Fixes #2871
This commit is contained in:
ridiculousfish 2017-01-31 10:58:06 -08:00
parent 56161250de
commit 8a09c99f36

View file

@ -64,7 +64,9 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
# Add way to kill current command line while in insert mode.
bind -M insert \cc __fish_cancel_commandline
# Add a way to switch from insert to normal (command) mode.
bind -M insert -m default \e backward-char force-repaint
# Note if we are paging, we want to stay in insert mode
# See #2871
bind -M insert \e "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end"
# Default (command) mode
bind :q exit