Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
3.39k stars 96 forks source link

[BUG] Completion failing on Ubuntu 20.04 (fzf version <= 0.20.0) #391

Closed fabian-thomas closed 9 months ago

fabian-thomas commented 1 year ago

See below for the final solution: https://github.com/Aloxaf/fzf-tab/issues/391#issuecomment-1962290542

The problem

Ubuntu 20.04 does ship fzf 0.20.0 which does not yet support the backward-delete-char/eof binding, therefore fzf-tab fails to query completion from fzf.

Here is the relevant debug output (bindkey "^I" fzf-tab-debug):

+-ftb-fzf:83> SHELL=zsh fzf --ansi '--bind=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof,bspace:down' '--bind=F1:reload(/usr/bin/zsh -f /home/fthomas/fzf-tab/lib/ftb-switch-group 139498 0 /tmp/zsh-fzf-tab-fthomas -1),F2:reload(/usr/bin/zsh -f /home/fth>
unknown action: backward-delete-char/eof
  +-ftb-fzf:100> ret=2
  +-ftb-fzf:102> ((  ! use_tmux_popup  ))
  +-ftb-fzf:103> echoti civis
  +-ftb-fzf:104> echoti cuu1
  +-ftb-fzf:107> rm /tmp/zsh-fzf-tab-fthomas/compcap.139498 /tmp/zsh-fzf-tab-fthomas/completions.139498 /tmp/zsh-fzf-tab-fthomas/ftb_preview_init.139498 /tmp/zsh-fzf-tab-fthomas/groups.139498
  +-ftb-fzf:108> return 2

Running the printed fzf command directly gives:

# SHELL=zsh fzf --ansi '--bind=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof' '--bind=F1:reload(/usr/bin/zsh -f /home/fthomas/fzf-tab/lib/ftb-switch-group 138359 0 /tmp/zsh-fzf-tab-fthomas -1),F2:reload(/usr/bin/zsh -f /home/fthomas/fzf-tab'
unknown action: backward-delete-char/eof

Temporary fix

This can be fixed by editing lib/-ftb-fzf and replacing the line that sets the binds from:

local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof

to

local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char,ctrl-h:backward-delete-char

(thereby just stripping the /eof)

Potential permanent fixes

Three come to my mind:

jwblangley commented 11 months ago

Thanks for the temporary fix!

jwblangley commented 11 months ago

If it is useful to anyone, the temporary fix can be written as a git patch, and applied with git apply <patch_file>, where <patch_file> has the following contents:

diff --git a/lib/-ftb-fzf b/lib/-ftb-fzf
index 2cb4228..b1158cf 100755
--- a/lib/-ftb-fzf
+++ b/lib/-ftb-fzf
@@ -28,7 +28,7 @@ if (( \$+ctxt[realdir] )); then
 fi
 $(typeset -p words)
 "
-local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof
+local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char,ctrl-h:backward-delete-char
 local fzf_command fzf_flags fzf_preview debug_command tmp switch_group fzf_pad fzf_min_height
 local ret=0
fabian-thomas commented 9 months ago

The final fix for zsh is the following in your zshrc:

zstyle ':fzf-tab:*' fzf-bindings-default 'tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char,ctrl-h:backward-delete-char'