From 7b5ccc45bc76f289fe2c48cf91e895b9ca99b1e2 Mon Sep 17 00:00:00 2001 From: Tom Fitzhenry Date: Sat, 15 Jul 2017 19:50:23 +1000 Subject: [PATCH] [fish] Fix ctrl-r regression in versions <2.4 (#972) Close #966 --- shell/key-bindings.fish | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 803d0a93..97a3ec55 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -39,8 +39,20 @@ function fzf_key_bindings set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40% begin set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m" - history -z | eval (__fzfcmd) --read0 -q '(commandline)' | perl -pe 'chomp if eof' | read -lz result - and commandline -- $result + + set -l FISH_MAJOR (echo $FISH_VERSION | cut -f1 -d.) + set -l FISH_MINOR (echo $FISH_VERSION | cut -f2 -d.) + + # history's -z flag is needed for multi-line support. + # history's -z flag was added in fish 2.4.0, so don't use it for versions + # before 2.4.0. + if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ]; + history -z | eval (__fzfcmd) --read0 -q '(commandline)' | perl -pe 'chomp if eof' | read -lz result + and commandline -- $result + else + history | eval (__fzfcmd) -q '(commandline)' | read -l result + and commandline -- $result + end end commandline -f repaint end