Skip to content

Commit 1a27e21

Browse files
committed
Merge zsh lazy completion fixes from blueyed
2 parents b1f020b + 94f1f21 commit 1a27e21

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

docs/source/history.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Release History
2323
command. (:bbissue:`203`)
2424
- Update the tests to use a valid template for creating temporary
2525
directories under Linux.
26+
- Fix the use of ``which`` in ``virtualenvwrapper_lazy.sh`` in case it
27+
is aliased.
28+
- Fix an issue with recursion in completion expansion crashing zsh,
29+
contributed by :bbuser:`blueyed`.
2630

2731
4.1.1
2832
=====

virtualenvwrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function virtualenvwrapper_run_hook {
229229
virtualenvwrapper.sh: There was a problem running the initialization hooks.
230230
231231
If Python could not import the module virtualenvwrapper.hook_loader,
232-
check that virtualenv has been installed for
232+
check that virtualenvwrapper has been installed for
233233
VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is
234234
set properly.
235235
EOF

virtualenvwrapper_lazy.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv
55

66
if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
77
then
8-
export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)"
8+
export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)"
99
fi
1010
if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
1111
then
@@ -14,7 +14,17 @@ fi
1414

1515
# Load the real implementation of the API from virtualenvwrapper.sh
1616
function virtualenvwrapper_load {
17-
source "$VIRTUALENVWRAPPER_SCRIPT"
17+
# Only source the script once.
18+
# We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets
19+
# a real completion.
20+
if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ]
21+
then
22+
# NOTE: For Zsh, I have tried to unset any auto-load completion.
23+
# (via `compctl + $(echo ${_VIRTUALENVWRAPPER_API})`.
24+
# But this does not appear to work / triggers a crash.
25+
source "$VIRTUALENVWRAPPER_SCRIPT"
26+
VIRTUALENVWRAPPER_LAZY_LOADED=1
27+
fi
1828
}
1929

2030
# Set up "alias" functions based on the API definition.
@@ -41,4 +51,6 @@ function virtualenvwrapper_setup_lazy_completion {
4151
}
4252

4353
virtualenvwrapper_setup_lazy_loader
54+
# Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv).
55+
# It also needs a second invocation, because the first one only sets up the real completion.
4456
virtualenvwrapper_setup_lazy_completion

0 commit comments

Comments
 (0)