Aloxaf / fzf-tab

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

[BUG] Preview causes "bad set of key/value pairs for associative array" #336

Open abhinav opened 1 year ago

abhinav commented 1 year ago

Describe the bug

I'm trying to use the preview feature with cd as advised in the README by adding the following:

zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'

I see the following error inside the preview window:

zsh:9: bad set of key/value pairs for associative array

I can make sure:

To Reproduce

  1. Set up preview for cd per README
  2. Type 'cd ' and press Tab
  3. Preview window contains error instead of preview

Expected behavior

Preview window contains a list of files in the directory.

Screenshots

Screen recording 2022-12-18 18.21.29.webm

Environment:

Minimal zshrc

If applicable, add a minimal zshrc to help us analyze.

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

source ~/.zsh/zsh-completions/zsh-completions.plugin.zsh
zstyle ':completion:*' completer _expand _complete _approximate
zstyle ':completion:*' file-sort name
zstyle ':completion:*' ignore-parents parent pwd directory
zstyle ':completion:*:*:-command-:*:*' ignored-patterns '_*'
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=1
zstyle ':completion:*' original true
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle :compinstall filename "$HOME/.zsh/rc.d/completion"

autoload -Uz compinit
compinit

source ~/.zsh/fzf-tab/fzf-tab.plugin.zsh
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'

Log

zsh-22539-fzf-tab-1.log


Just to narrow it down, I added set -x to ftb_preview_init inside lib/-ftb-fzf. That gives me,

+zsh:3> zmodload zsh/mapfile                                                                  │
+zsh:4> local -a _ftb_compcap=( $'bin\C-B<\C-@>\C-@realdir\C-@\C-@args\C-@-Q\C-A-s\C-A\C-A-W\ │
+zsh:5> local -a _ftb_groups=( '' '' )                                                        │
+zsh:6> local bs=$'\C-B'                                                                      │
+zsh:8> export desc=' bin'                                                                    │
+zsh:10> local -A ctxt=( '' )                                                                 │
zsh:10: bad set of key/value pairs for associative array                                      │

ctxt has only one item instead of the two needed for the associative array.