You click on some file which is a symlink to some project files. IntelliJ IDEA / PyCharm doesn't recognize this, and opens the file as outside the project, even in the case it is already opened.
There are a number of related bug reports, such as: #12783, #20544, #20716, #39030, #49461, #82863, #141650, #204031, #256182
This IDEA plugin resolves at least the open issues, by always resolving all symlinks.
The plugin is available in the marketplace here. In the IDE, select Settings or Preferences -> Plugins -> Marketplace, search for "IDEA Resolve Symlinks", and you should find it.
- Download the latest zipped JAR file from the releases.
- Unzip, so you get the JAR file.
- In the IDE, select Settings or Preferences -> Plugins -> Install Plugin from Disk ..., select the JAR file.