Skip to content

Commit 7c94c07

Browse files
committed
Merge branch 'fix-zsh-lazy-completion'
Getting all fixes into my master, although it has a pull request: feel free to nag me about cleaning it up, but the relevant commits should be easy to cherry-pick from here. I will keep fix-zsh-lazy-completion in a separate branch.
2 parents a8f330a + 6a21bcd commit 7c94c07

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

virtualenvwrapper_lazy.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 ]; then
21+
if [ -n "$ZSH_VERSION" ] ; then
22+
# Tried to unset any auto-load completion, does not appear to work/triggers a crash
23+
# compctl + $(echo ${_VIRTUALENVWRAPPER_API})
24+
fi
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)