1

I'm having some issues with the "Go To Definition" feature in Visual Studio Code and Python code. To note, I haven't tested with other coding languages. The feature works well for functions and variables within the same open file but it does not work for files being imported such as custom classes or custom .py files that I import. This is true even if the file/class in question is open in another tab.

Screen Capture

Is there a reason for this? If so, can it be fixed?

TheNomad
  • 293
  • 1
  • 3
  • 10
  • Which language server are you using? I.e. what is `"python.jediEnabled"` set to? Have you tried the opposite value to see what that results in? – Brett Cannon Apr 29 '20 at 21:51
  • @BrettCannon I have "python.jediEnabled": false since I am using Visual Studio IntelliCode – TheNomad Apr 30 '20 at 22:04
  • @BrettCannon I have. Then VSCode throws an error stating that the IntelliCode requires other engines to be disabled and then the jediEnabled setting gets set to false automatically. – TheNomad May 01 '20 at 13:46
  • Correct, IntelliCode does not work with Jedi. – Brett Cannon May 06 '20 at 22:15
  • Thanks @BrettCannon. it seems that even with IntelliCode "off" and Jedi "on" the "Go To Definition" does not work. – TheNomad May 08 '20 at 00:04
  • If you can come up with a small, reproducible example then please open an issue at https://github.com/microsoft/vscode-python – Brett Cannon May 12 '20 at 20:22

1 Answers1

0

see Pylint "unresolved import" error in Visual Studio Code explains how to modify .vscode/settings.json by adding "python.autoComplete.extraPaths": ["./path-to-your-code"]

Jason Harrison
  • 922
  • 9
  • 27
  • Thanks @JasonHarrison. I tried adding the extraPaths as suggested but it still did not work. Maybe I'm missing something? I added the path as follows: "python.autoComplete.extraPaths": ["C:/Repositories"] and "python.autoComplete.extraPaths": ["C:/Repositories/"], none of which worked. – TheNomad Dec 03 '20 at 17:02
  • Please try paths that result in directories where your py files are. I had to add my subdirectories. – Jason Harrison Dec 04 '20 at 18:56
  • Thanks @JasonHarrison. I tried adding the path(s) as you suggested, but it still doesn't work. I'm using PyLance, so, the python.autoComplete.extraPaths has be replaced by python.analysis.extraPaths. – TheNomad Dec 07 '20 at 19:00