0

While using VS Code, I like to use the F12 'Go to Definition' feature often. The issue I have with this is that it always opens local cached versions of the scripts and never the ones I have opened in folder view. Is there a way to restrict this feature to only look at what files I have opened in the folder view?

Mocked up a quick example here: enter image description here

In the above image, I highlight the print_string function and press F12. This opens up the local cached version seen on the right side that is in my C:\Temp\ folder, rather than opening the file from within my_repo folder that I currently have opened on the far left.

Side note that this was all setup by hand just to show the example and if you tried this, it wouldn't actually do this. In the real issue with my other code, the cached code is from another program that downloads the whole repo locally.

I've tried looking at all of the different hotkey's available. I've looked into the different excludes (files: exclude and search: excludes) and nothing I tried worked, but I may have been putting in the patterns wrong. I was trying something like this: **/Temp. I've also looked into some config files that may work but was unable to find anything specifically for what I am looking for.

I've also tried using the following settings in the settings.json:

    "python.autoComplete.extraPaths": [
        "D:/my_repo/**"
    ],
    "python.analysis.extraPaths": [
        "D:/my_repo/**"
    ],
    "python.analysis.include": [
        "D:/my_repo/**"
    ],
    "python.analysis.exclude": [
        "C:/Temp/**"
    ]
  • did you open that file from the temp folder before in VS Code? What if you just clear it form the recent files list? (open the "quick open" dialog, find it, and press the X button to its right to make VS Code "forget" that you opened it before) – starball Apr 06 '23 at 20:46
  • @user I did not open the file from that location. I'm not actually sure how it is being referenced instead at the moment. – user1774816 Apr 06 '23 at 21:43
  • Why is there a cached version? Can't reproduce your problem. If you have a reproducible example please report it on [GitHub](https://github.com/microsoft/vscode-python/wiki/Reporting-a-bug). Also modifying the settings `"python.autoComplete.extraPaths": ["./"],` and `"files.exclude": { "**/Temp": true } ` may be useful. – JialeDu Apr 07 '23 at 05:56

0 Answers0