ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
20.33k stars 519 forks source link

Interactive expansion doesn't work as expected when it matches a single entry then echos command 3 times #780

Closed ashleybartlett closed 2 months ago

ashleybartlett commented 3 months ago

This was working, and no longer is. I'm still not a daily driver of zoxide, so can't report on when exactly it stopped working. I did do some upgrades of packages recently (using brew), so could be an incompatibility of new versions? Not sure what else could be causing the problem.

When using z path<SPACE><TAB> it cd's into that directory, and then echos the current directory: SCR-20240405-khjf

Here are what are likely relevant package versions currently installed:

fzf 0.49.0
zoxide 0.9.4
zsh-autocomplete 23.07.13
zsh 5.9 (x86_64-apple-darwin23.0)

I'm using oh-my-zsh but not any plugins, i've got auto-complete being loaded in my .zshrc file, as below (in order)

source $ZSH/oh-my-zsh.sh
source $(brew --prefix)/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh

eval "$(fzf --zsh)"
# Other auto-completions
eval "$(zoxide init zsh)"

Any ideas? Is this a bug? I can see that fzf is still working in my shell.

argamanza commented 3 months ago

Looks like the same issue I'm having #775

ashleybartlett commented 3 months ago

Yeah, looks to be the same issue

ashleybartlett commented 3 months ago

I ran again with setopt xtrace enabled, and the interesting thing is that is that it calls the _zoxide_z function, then _zoxide_cd. I can't see anything obvious wrong here.

I no longer suspect this is something to with fzf.

It's curious that it replaces my search word with an auto-completed entry, and then activates the command. I never hit enter.

ashleybartlett commented 3 months ago

Further investigation shows that this appears to only be an issue where there is a single match in the database, and it tries to CD, rather than initiate the interactive mode.

ashleybartlett commented 2 months ago

Uhh, I think i've found the problem, I put up a PR, but it's not the root problem. It looks like the zsh completions are being called multiple times causing the weirdness

ashleybartlett commented 2 months ago

Raised a PR to fix this https://github.com/ajeetdsouza/zoxide/pull/785