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
- Enable plugin poetry-env
- Create a folder with poetry environment (.venv folder and pyproject.toml file)
- Change to the folder with the poetry environment: the environment gets activated
- Create a subdirectory in this folder
- 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!