Example:
- I Have
/mnt/extra-drive/Git
that contains multiple projects - I symlinked this directory to
~/Git
ln -s /mnt/extra-drive/Git ~/Git
- And I open the projects using vscode from this new directory
~/Git
- When I open any file from the sidebar it opens from
~/Git/project
as normal - But if I tried to "Go to Defenition" from Python class (I'm using the
ms-python.python
extension), it redirects me to the Python file from/mnt/extra-drive/Git/project
, I want it to open from~/Git/project
to reflect on the sidebar "Explorer View" correctly
Any Solution to that?
This was a bug, which is now fixed in (prerelease) version 2023.11.102. See the changelog
Old answer
An issue ticket was raised to the Python extension maintainers by the asker of the question and they categorized it as a bug. Open GoTo definition performs symlink resolution #5136. Also related is Rename symbol in a symbolic py file opens source file #5030.
VS Code itself is not responsible for whether or not symlink resolution happens or not when Go To Definition happens. It's the responsibility of whichever language support extension implements it using VS Code's extension API. Many other language support extensions have the same type of issue. See also
For anyone else reading this, I suggest that you give that issue ticket a thumbs up to show support for it and increase its prioritization. You can also subscribe to it to get notified about discussion and progress. But please avoid making noisy comments there like ones that just consist of "+1" / "bump" (just give it a thumbs up if that's what you want to convey).