bugfix(plugin): correctly switch VENV when transitioning between projects directly

Properly deactivate shell if you move directly from one poetry env to another otherwise you get stuck in the old virtual env unless you hit a non poetry directory first which would trigger the deactivate command.
This commit is contained in:
Kate Sullivan 2024-11-13 19:07:45 -06:00 committed by GitHub
commit bc383878e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,11 +6,10 @@ _togglePoetryShell() {
fi
# Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
if [[ $poetry_active -eq 1 ]] && [[ $in_poetry_dir -eq 0 ]] \
&& [[ "$PWD" != "$poetry_dir"* ]]; then
if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] || [[ "$PWD" != "$poetry_dir"* ]]; }; then
export poetry_active=0
unset poetry_dir
(( $+functions[deactivate] )) && deactivate
deactivate
fi
# Activate the environment if in a Poetry directory and no environment is currently active