"Always select opened file" appears broken with dependencies between subprojects
Im working with multiple python packages, where some packages are dependencies to others.
All the packages are opened as attached subprojects to a main project. Everything is installed in a common virtual environment, where the local dependencies are installed as 'editable' using pip.
https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
Each sub project is configured to use the same python interpreter in the common virtual environment.
When the packages are installed as editable, they appear in each sub-project as a blue 'sources root' folder, correctly indicating that the dependency is in a local directory. So far so good.
The issue i have is when using the "Always select opened file" option. This option will select all the copies of the same file, the actual location of the file, as well as all the copies opened in different sub projects. Since all of these locations are in different places in the project tree, and they may not fit in the same view, it effectively jumps to a random location in the project tree.
So in effect, when editing a package and jumping between files within it, the project tree does not stay focused on that subroproject, but jumps around to unrelated places where the files appear as dependencies.
Here is an example with two subprojects that illustrates the issue, the real issue appear where the project no loger fit in the window. 
is there any way to configure the IDE to remedy this? can you configure the select behaviour, or turn off the dependecy folders showing up in the IDE?
Please sign in to leave a comment.
Hi, is it possible to share the sample project (e.g. via a temporary GitHub repo) and provide steps to reproduce the issue (which packages to install, etc.)?
This would save time greatly trying to reproduce the issue.
Thank you , i posted the example to Github.
https://github.com/joel-odlund/pycharm-issue
This example reproduces that the IDE selects multiple files. In this example, it happens to scroll to the expected file. In other settings it can also scroll to any of the other folders, but i was not able to reproduce that in this example. Hopefully, the example can still be useful.
Thank you very much for the project sample, but unfortunately I couldn't reproduce the issue so far. The file tree of the project looks like this:
I don't understand why the src directory is mirrored between package a and b in your case. Could you please elaborate?
Hi again. did you follow the steps in the readme?
When i do, i get package b opened as a 'python module' in pycharm, that is with a python logo on the icon in the project view, and all the source roots listed under it. this is why i see src from package_a, its added automatically as a sources root to package b.
(here we have a problem in itself, package_b is in not a 'python module', its just a directory with a python file in it.)
There seems to be a more fundamental issue here. When opening several projects that share the same virtual environment, where the projects/python packages themselves are installed as editable, each subproject (aka pycharm module?) gets the src dir of each module added as sources root. This seems to be an invalid state, as if i remove one of the content roots in a subproject and add it back, i get an error that two projects cannot share the same content root.
This is all very hard to communicate but appears to be a fundamental problem. We seem to have,
When installing the modules as editable, it seems like pycharm configures itself in violation with 5 to make it work. can this be the reason of the unexpected behavior with multiople files selected and random scrolling?
Ah, sorry, I must have been doing something incorrectly. Repeated the test again and reproduced this behavior. It seems that you can remedy this by removing the content root from package_b:
You can keep working on both packages, but the duplicated structure should disappear. I'm not sure what other consequences it may have on your project, but please try it if you haven't already.