ea8068aa3eeecc785249f2e83289e8a9294b9d6b

Author
Carlo Sala <carlosalag@protonmail.com>
Committer
Carlo Sala <carlosalag@protonmail.com>
Date

Message

fix(tailscale): make completion loading async

Diff

 1diff --git a/plugins/tailscale/tailscale.plugin.zsh b/plugins/tailscale/tailscale.plugin.zsh
 2index ae664a6653029ab134d9ac779c7f1faf17b4094c..7f0b1414aec327e684919cc9c077019e202ca669 100644
 3--- a/plugins/tailscale/tailscale.plugin.zsh
 4+++ b/plugins/tailscale/tailscale.plugin.zsh
 5@@ -1,4 +1,13 @@
 6+if (( ! $+commands[tailscale] )); then
 7+  return
 8+fi
 9 
10-if [ $commands[tailscale] ]; then
11-  source <(tailscale completion zsh)
12+# If the completion file doesn't exist yet, we need to autoload it and
13+# bind it to `tailscale`. Otherwise, compinit will have already done that.
14+if [[ ! -f "$ZSH_CACHE_DIR/completions/_tailscale" ]]; then
15+  typeset -g -A _comps
16+  autoload -Uz _tailscale
17+  _comps[tailscale]=_tailscale
18 fi
19+
20+tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &|