fix(poetry-env): only run `deactivate` if needed (#12701)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Diff
1diff --git a/plugins/poetry-env/poetry-env.plugin.zsh b/plugins/poetry-env/poetry-env.plugin.zsh
2index be46717d8f5b67ffa1b1b84233b0138065fb8c1e..dd52b165548a28d4e1694864fba53226bc802caf 100644
3--- a/plugins/poetry-env/poetry-env.plugin.zsh
4+++ b/plugins/poetry-env/poetry-env.plugin.zsh
5@@ -6,10 +6,11 @@ _togglePoetryShell() {
6 fi
7 8 # Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
9- if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] && [[ "$PWD" != "$poetry_dir"* ]]; }; then
10+ if [[ $poetry_active -eq 1 ]] && [[ $in_poetry_dir -eq 0 ]] \
11+ && [[ "$PWD" != "$poetry_dir"* ]]; then
12 export poetry_active=0
13 unset poetry_dir
14- deactivate
15+ (( $+functions[deactivate] )) && deactivate
16 fi
1718 # Activate the environment if in a Poetry directory and no environment is currently active