Commits

Daniel Hahler committed 6a21bcd

Fix zsh crash caused by lazily loading the completions

Should be considered work in progress: please pick it up.

See https://bitbucket.org/dhellmann/virtualenvwrapper/issue/215

  • Participants
  • Parent commits f0f0077

Comments (0)

Files changed (1)

virtualenvwrapper_lazy.sh

 
 # Load the real implementation of the API from virtualenvwrapper.sh
 function virtualenvwrapper_load {
-    source "$VIRTUALENVWRAPPER_SCRIPT"
+    # Only source the script once.
+    # We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets
+    # a real completion.
+    if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ]; then
+        if [ -n "$ZSH_VERSION" ] ; then
+            # Tried to unset any auto-load completion, does not appear to work/triggers a crash
+            # compctl + $(echo ${_VIRTUALENVWRAPPER_API})
+        fi
+        source "$VIRTUALENVWRAPPER_SCRIPT"
+        VIRTUALENVWRAPPER_LAZY_LOADED=1
+    fi
 }
 
 # Set up "alias" functions based on the API definition.
 }
 
 virtualenvwrapper_setup_lazy_loader
+# Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv).
+# It also needs a second invocation, because the first one only sets up the real completion.
 virtualenvwrapper_setup_lazy_completion