ohmyzsh / ohmyzsh

🙃 A delightful community-driven (with 2,300+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.

Home Page:https://ohmyz.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

poetry-env gets deactivated if changing to a sub directory

Svdvoort opened this issue · comments

Describe the bug

Previous versions of the poetry-env plugin allowed changing to a subdirectory of a poetry directory while keeping the virtual environment active. With the new version changing into a subdirectory will deactivate the environment

Steps to reproduce

  1. Enable plugin poetry-env
  2. Create a folder with poetry environment (.venv folder and pyproject.toml file)
  3. Change to the folder with the poetry environment: the environment gets activated
  4. Create a subdirectory in this folder
  5. Change to the subdirectory: the environment gets deactivated

Expected behavior

The environment should stay activated even with subdirectories and only change when changing to a directory that is does not contain a poetry environment or is not a subdirectory of a directory that contains a poetry environment.

Screenshots and recordings

No response

OS / Linux distribution

Ubuntu 22.04

Zsh version

5.8.1

Oh My Zsh version

master (ee69c14)

Terminal emulator

GNOME terminal

If using WSL on Windows, which version of WSL

None

Additional context

Related to #12346.
Specifically here line 9.
in_poetry_dir will always be 0 when going from the main poetry directory to a subdirectory and poetry_active will always be 1 in that case, so the environment gets deactivated.
Probably the or-check here should be an and-check: we need to make sure that we are not in a poetry directory and not in a subdirectory of the poetry directory we were in earlier before we deactivate the environment.

I agree, fixed! Thanks for the report!