Idempotency: Enable the plugin to be source
d more than once in the same shell session #283
Description
zsh-autocomplete
version: 7f44a6d- Zsh version: zsh-5.8-0-g77d203f
- Framework: none
- Plugin manager: none
Not sure if this should be categorized as a feature request or bug report. It would be nice if the module was idempotent; so that it works correctly after being sourced multiple times (my scripts automatically resource everything when my .zshrc timestamp changes). Currently, simply sourcing it twice breaks completion (just doesn't display anything when typing commands) and history searching:
.autocomplete._main_complete:9: maximum nested function level reached; increase FUNCNEST?
.autocomplete._main_complete:unfunction:12: no such hash table element: compadd
.autocomplete._main_complete:unfunction:12: no such hash table element: compadd
...
autocomplete._main_complete:unfunction:12: no such hash table element: compadd
_main_complete:unfunction:20: no such hash table element: compadd
$ cd ~zsh-autocomplete
$ git switch main # Make sure you test with the `main` branch.
$ git pull # Update to the latest commit.
$ cd $(mktemp -d) # Create a temp dir and enter it.
$ # Restart Zsh without config files or environment variables in this dir:
$ exec env -i HOME=$PWD PS1='%# ' TERM=$TERM zsh -f
% source /path/to/zsh-autocomplete/zsh-autocomplete.plugin.zsh
% source /path/to/zsh-autocomplete/zsh-autocomplete.plugin.zsh
<try typing and there's no autocomplete>
<try arrow up for history search>
BTW; thanks for the great work and sharing your plugin.