marlonrichert / zsh-autocomplete

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
MIT License
5.37k stars 149 forks source link

recent path search not working for new paths #752

Open ajilty opened 1 month ago

ajilty commented 1 month ago

Environment

% 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=(
  /var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/zsh-autocomplete/zsh-autocomplete.plugin.zsh:4
  /var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/.zshrc:9
  zsh:0

% git -C ~autocomplete log --oneline -n1
762afac (grafted, HEAD -> main, tag: 24.09.04, origin/main, origin/HEAD) Add note to Readme about usage of `%`

Steps to reproduce

% cd $(mktemp -d)
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
Cloning into 'zsh-autocomplete'...
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (51/51), done.
remote: Total 53 (delta 0), reused 31 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (53/53), 1.64 MiB | 13.75 MiB/s, done.

% > .zshrc <<EOF
setopt interactivecomments transientrprompt
PS1='%# '
PS2=
RPS2='%^'

source /var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/zsh-autocomplete/zsh-autocomplete.plugin.zsh

autoload -Uz chpwd_recent_dirs cdr
add-zsh-hook chpwd chpwd_recent_dirs

EOF
% env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
% mkdir -p foo/bar/yummy  
% cd foo/bar 
% cd yummy
% cd ~
% cdr -l
1    /private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/foo/bar/yummy
2    /private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/foo/bar
3    /private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi

% tail ~/.local/share/zsh/chpwd-recent-dirs
$'/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi'
$'/private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/foo/bar/yummy'
$'/private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/foo/bar'
$'/private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi'

% +autocomplete:recent-directories
% echo $reply
/private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/foo/bar/yummy /private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/foo/bar /private/var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi

# type `yummy`, hit tab, no suggestions
# up arrow does do the normal things
Contents of /var/folders/j6/pjs4p22d77v7bvs6ds534c140000gp/T/tmp.gmBn94rnKi/.local/state/zsh-autocomplete/log/2024-09-12.log (click to expand)
(empty)
Rayzeq commented 1 month ago

I have the same issue I'm on Nixos with zsh-5.9-0-g73d3173. Completions for recent directories works with 23.07.13 but not with 24.09.04.

faileon commented 1 month ago

I guess the latest release changed the behaviour,

https://github.com/marlonrichert/zsh-autocomplete/commit/a8fdd21227d76e077ad034c6ff7108ae44bd57a7 Move recent paths completion to a keybinding. Resolves https://github.com/marlonrichert/zsh-autocomplete/issues/640.

Is there a way to get the old one back? My autocompletions now no longer suggest the paths I use the most. for example I could write $ cd abc and the autocomplete would suggest ~/Projects/company/abc which was super neat

faileon commented 1 month ago

@marlonrichert do you have any suggestions please?

tommeier commented 1 week ago

ah this is what broke recent-directories - I thought it was upgrading to sequoia - is downgrading the version in homebrew possible 🤔

tommeier commented 1 week ago

For those that miss autocomplete on ~/Projects/company/abc as much as me 😅

brew uninstall zsh-autocomplete
brew tap homebrew/core --force
brew extract --version=23.07.13 zsh-autocomplete $USER/local-zsh-autocomplete
brew install zsh-autocomplete@23.07.13
brew pin zsh-autocomplete@23.07.13

You'll then need to update your source, eg: source /path/to/zsh-autocomplete/zsh-autocomplete.plugin.zsh -> source /path/to/zsh-autocomplete@23.07.13/zsh-autocomplete.plugin.zsh (for me /path/to == brew --prefix) and then autocomplete recent-directories working as before 🎉

faileon commented 6 days ago

Downgrading is surely a possible workaround. Hopefully it won't be the only solution and we can get this behavior back to the new versions :]