From bc383878e41451a271b6fb2c60a80a6c51163777 Mon Sep 17 00:00:00 2001 From: Kate Sullivan <75387802+katesullivan@users.noreply.github.com> Date: Wed, 13 Nov 2024 19:07:45 -0600 Subject: [PATCH] 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. --- plugins/poetry-env/poetry-env.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/poetry-env/poetry-env.plugin.zsh b/plugins/poetry-env/poetry-env.plugin.zsh index dd52b1655..f98c177b4 100644 --- a/plugins/poetry-env/poetry-env.plugin.zsh +++ b/plugins/poetry-env/poetry-env.plugin.zsh @@ -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