Commits

Doug Hellmann committed 1a27e21 Merge

Merge zsh lazy completion fixes from blueyed

  • Participants
  • Parent commits b1f020b, 94f1f21

Comments (0)

Files changed (3)

File docs/source/history.rst

   command. (:bbissue:`203`)
 - Update the tests to use a valid template for creating temporary
   directories under Linux.
+- Fix the use of ``which`` in ``virtualenvwrapper_lazy.sh`` in case it
+  is aliased.
+- Fix an issue with recursion in completion expansion crashing zsh,
+  contributed by :bbuser:`blueyed`.
 
 4.1.1
 =====

File virtualenvwrapper.sh

 virtualenvwrapper.sh: There was a problem running the initialization hooks. 
 
 If Python could not import the module virtualenvwrapper.hook_loader,
-check that virtualenv has been installed for
+check that virtualenvwrapper has been installed for
 VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is
 set properly.
 EOF

File virtualenvwrapper_lazy.sh

 
 if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
 then
-    export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)"
+    export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)"
 fi
 if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
 then
 
 # 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
+        # NOTE: For Zsh, I have tried to unset any auto-load completion.
+        #       (via `compctl + $(echo ${_VIRTUALENVWRAPPER_API})`.
+        #       But this does not appear to work / triggers a crash.
+        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