Repository: marlonrichert/zsh-autocomplete

Issue #706: Incompatibility with zoxide z <space><tab> shortcut
Created: 2024-03-22T22:44:51Z
When installing and using zsh-autocomplete with z-shell/zsh-zoxide,
zoxide command is repeated 4 times when using the shorcut
z <directory-to-search><SPACE><TAB>
and does not validate in the end
Environment

% typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocomplete__funcfiletrace
typeset VENDOR=pc
typeset OSTYPE=linux-gnu
typeset ZSH_PATCHLEVEL=zsh-5.9-0-g73d3173
typeset -a _autocomplete__funcfiletrace=(
  /home/aacebedo/.zi/plugins/marlonrichert---zsh-autocomplete/zsh-autocomplete.plugin.zsh:4
  /home/aacebedo/.zi/bin/zi.zsh:1623
  /home/aacebedo/.zi/bin/zi.zsh:1516
  /home/aacebedo/.zi/bin/zi.zsh:1215
  /home/aacebedo/.zi/bin/zi.zsh:2507
  /home/aacebedo/.zshrc:7
  zsh:0
)
% git -C ~autocomplete log --oneline -n1
c7b6550 (HEAD -> main, origin/main, origin/HEAD) Add instructions on how to insert longest common prefix

Operating system: NixOS
Terminal emulator: Alacritty

Steps to reproduce

% cd $(mktemp -d)
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
<output>
% > .zshrc <<EOF
setopt interactivecomments transientrprompt
PS1='%# '
PS2=
RPS2='%^'
if [ ! -d ~/.zi ]; then
  source <(curl -sL init.zshell.dev); zzinit
fi
. ~/.zi/bin/zi.zsh
mkdir -p ~/.zi/completions
zi ice depth "1"
zi load romkatv/powerlevel10k
zi load marlonrichert/zsh-autocomplete
zi load z-shell/zsh-zoxide
zi cdreplay -q
EOF
% env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
% cd /etc
% x e<SPACE><TAB>
x /etc
x /etc
x /etc
x /etc

Duplicate issue #709: Conflict between zoxide, zsh-autocomplete, and fzf results in erroneous behavior
Created: 2024-03-29T21:12:25Z
Environment
Shell: zsh 5.9
OS: macOS 14.1
Tools & Versions:
zoxide: 0.9.4
fzf: 0.48.1 (installed via brew)
zsh-autocomplete: 23.07.13
% typeset -p1 VENDOR OSTYPE ZSH_PATCHLEVEL _autocomplete__funcfiletrace
typeset VENDOR=apple
typeset OSTYPE=darwin23.0
typeset ZSH_PATCHLEVEL=zsh-5.9-0-g73d3173
typeset -a _autocomplete__funcfiletrace=(
  /opt/homebrew/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh:4
  /Users/tzahi.argaman/.zshrc:5
  zsh:0
)
% git -C ~autocomplete log --oneline -n1
92a4311868 (HEAD -> stable, tag: 4.2.15) Merge pull request #16944 from cho-m/mismatched_binary_allowlist-granular-globs
Description
When using zoxide in conjunction with zsh-autocomplete and fzf, the expected behavior of navigating to directories sorted by frecency fails. Specifically, after initiating a directory search with z prefix<SPACE><TAB>, selecting a directory from the fzf menu, and pressing <ENTER>, the fzf menu reopens with the input "0n" instead of changing the directory.
Steps to Reproduce

Configure .zshrc with the following setup:

# Set up fzf key bindings and fuzzy completion
eval "$(fzf --zsh)"

# Initialize zsh-autocomplete
source /opt/homebrew/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh

# Initialize zoxide
eval "$(zoxide init zsh)"


Type z sometext<SPACE><TAB> to invoke the fzf menu.
Select a directory and press <ENTER>.

Expected Behavior
Upon selecting a directory from the fzf menu and pressing <ENTER>, the shell should navigate to the selected directory.
Actual Behavior
After selecting a directory, pressing <ENTER> reopens the fzf menu with 0n pre-filled, leading to an empty list. Exiting this state requires pressing <ESCAPE> three times or manually correcting the input.
Additional Information

When using zoxide on a directory prefix with only one possible completion it will paste the command 4 times and cd into it.
This issue does not occur when zsh-autocomplete is not initialized in the .zshrc file.
using zi works as expected, seems like the issue is with the <TAB> key press.
I will attach a video demonstrating the described behavior.

Attempts to Resolve
Using autoload -U compinit; compinit as demonstrated below, instead of the zsh-autocomplete initialization allows zoxide to function as expected but without the desired autocomplete features.
autoload -U compinit; compinit

# Initialize zsh-autocomplete
source /opt/homebrew/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh

# Initialize zoxide
eval "$(zoxide init zsh)"

TL;DR
When using zoxide in conjunction with zsh-autocomplete, pressing <TAB> performs some action 4 times which leads to erroneous behavior.
Issue Demonstration


Contents of ~autocomplete-log/YYYY-MM-DD.log (click to expand)
cat ~autocomplete-log/2024-03-29.log
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
**Following lines are automatically added when trying to `cat` the log file**
^[[2;1R^[[10;1R^[[25;1R^[[25;1R%
tzahi.argaman@NG-TZAHI-AR % 1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R;1R
shell function
TRAPINT   TRAPQUIT
common substring: TRAPI

Closing comment (2024-04-02T16:27:29Z): Just noticed it's a duplicate of #706 - closing