Browse Source

fix(poetry-env): only run `deactivate` if needed (#12701)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Alex Rosenfeld 1 month ago
parent
commit
0987eee190
1 changed files with 3 additions and 2 deletions
  1. 3 2
      plugins/poetry-env/poetry-env.plugin.zsh

+ 3 - 2
plugins/poetry-env/poetry-env.plugin.zsh

@@ -6,10 +6,11 @@ _togglePoetryShell() {
   fi
   fi
 
 
   # Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
   # 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
     export poetry_active=0
     unset poetry_dir
     unset poetry_dir
-    deactivate
+    (( $+functions[deactivate] )) && deactivate
   fi
   fi
 
 
   # Activate the environment if in a Poetry directory and no environment is currently active
   # Activate the environment if in a Poetry directory and no environment is currently active