Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idempotency: Enable the plugin to be sourced more than once in the same shell session #283

Closed
cpakkala opened this issue Jun 2, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@cpakkala
Copy link

cpakkala commented Jun 2, 2021

  • 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.

@cpakkala cpakkala added the bug Something isn't working label Jun 2, 2021
@marlonrichert marlonrichert added enhancement New feature or request and removed bug Something isn't working labels Jun 3, 2021
@marlonrichert
Copy link
Owner

I consider that a feature request. 🙂 Sure, it's possible, but it will require some work, since zsh-autocomplete patches a lot of existing functions. I will have to give this some thought.

@Timoses
Copy link

Timoses commented Jul 8, 2021

This would be very nice as sourcing ~/.zshrc is quite a common task after updating it.

Additionally, I seem to find that sourcing ~/.zshrc and thereby reloading zsh-autocomplete triggers #298 .

@brianrobt
Copy link

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:

This would be very nice to have. In the meantime, do we have a workaround?

@marlonrichert
Copy link
Owner

marlonrichert commented Jul 21, 2021

In the meantime, do we have a workaround?

@thompsonbrian Yes: Use exec zsh to restart your shell.

@marlonrichert
Copy link
Owner

It's there now. Enjoy!


PS: If you enjoy using my software, please consider sponsoring me. 🙂

@marlonrichert marlonrichert changed the title Idempotency? Idempotency: Make it possible to source the plugin more than once in the same shell session Sep 22, 2021
@marlonrichert marlonrichert changed the title Idempotency: Make it possible to source the plugin more than once in the same shell session Idempotency: Enable the plugin to be sourced more than once in the same shell session Sep 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants