Skip to content

Multi-root workspace support prevents extension from recognizing files outside workspace #5132

Description

With the multi-root workspace support added in #4244, files which do not reside in a workspace (including library code that doesn't live in a virtualenv inside the opened folder) are not properly classified, and the extension/editor does not recognize them. This affects goto-def (see microsoft/python-language-server#840), but also opening random files that aren't in the currently open folder.

This behavior likely comes from this line: https://github.com/Microsoft/vscode-python/pull/4244/files#diff-f60110caa225d7026d0cffec5d66270fR109

Which I interpret to mean "only treat files within this root as Python", as well as to help distinguish one workspace from another. This has the unfortunate side effect of preventing files that don't match those patterns from "being" Python and then handled by the extension.

Interestingly, if you open a file (and have it not be recognized), then reload VS Code, then the file is recognized as normal, which may hint that there's a way to avoid the problem (or that it's just a bug).

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Apr 5, 2019
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Apr 5, 2019
  3. added
    triage-neededNeeds assignment to the proper sub-team
    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.
    on Apr 5, 2019
  4. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Apr 5, 2019
  5. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Apr 5, 2019
  6. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Apr 5, 2019
  7. 30 remaining items

  8. ErwanDL commented on Mar 25, 2020

    @ErwanDL

    I am having an issue where the Microsoft Python Language Server stops working when editing and switching between files in different workspaces, when in a multi-root workspace environment. I reported this issue on the MPLS repo (microsoft/python-language-server#1962) : the maintainers there believe that my crash issue is rather on the side of the Python extension, and that is is probably linked (if not identical) to this very issue.

    Steps to reproduce :

    • Create 2 folders with one Python file in each, respectively called test1.py and test2.py.
    • Add these 2 folders to a new Multi-Root Workspace, and open this Multi-Root Workspace with VSCode.
    • Open test1.py. Hover on variable names, try to import modules, assert that everything is working OK.
    • Open test2.py. Hover on variable names, try to import modules, assert that everything is also working OK.
    • Switch back to test1.py : intellisense, hovering, auto-complete of import paths should not be working anymore.
    • Everything should still be working fine for test2.py though.
  9. jakebailey commented on Apr 21, 2020

    @jakebailey
    MemberAuthor

    I traced the above issue down while working on another multi-root LS PR; I'll file that as another bug as I believe it's a regression from a release earlier this year (#8815) to do with only having a single LS running at a time depending on the user's activity.

  10. kcajf commented on Jun 8, 2020

    @kcajf

    I've got the same problem, where intellisense will stop working when I change between files in my multi-root workspace. I can reproduce it consistently by opening vscode with a file in one workspace, changing to a file in the other workspace, then changing back. Any fix or workaround would be great.

  11. lihuanshuai commented on Jul 17, 2020

    @lihuanshuai

    I switch to Pylance, it is not perfect, but it works when multi-root worksapce

  12. ErwanDL commented on Jul 17, 2020

    @ErwanDL

    Yep, Pylance is definitely the way to go now, I also did the switch and it works better. I think support for the MPLS is going to be progressively dropped as well, as Pylance is now Microsoft's main Python LS if I'm not mistaken.

  13. karrtikr commented on Oct 22, 2021

    @karrtikr

    Is this still an issue once Microsoft Language Server is gone?

  14. jakebailey commented on Oct 22, 2021

    @jakebailey
    MemberAuthor

    Nope, Pylance handles workspaces natively. This was a bug with the hacky logic we had to use to spin up multiple MPLS instances.

  15. locked as resolved and limited conversation to collaborators on Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable buginvestigatingWe are looking into the cause of the issueverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions