Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jakebailey opened this issue Apr 5, 2019 · 13 comments
Assignees
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug investigating We are looking into the cause of the issue verified Verification succeeded
Milestone

Comments

@jakebailey
Copy link
Member

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).

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Apr 5, 2019
@DonJayamanne DonJayamanne added the P0 label Apr 5, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Apr 5, 2019
@DonJayamanne DonJayamanne added triage-needed Needs assignment to the proper sub-team area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. labels Apr 5, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Apr 5, 2019
@DonJayamanne DonJayamanne added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Apr 5, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Apr 5, 2019
@DonJayamanne DonJayamanne self-assigned this Apr 5, 2019
@DonJayamanne DonJayamanne added important Issue identified as high-priority and removed P0 labels Apr 16, 2019
@brettcannon brettcannon changed the title Multi-root workspace supports prevents extension from recognizing files outside workspace Multi-root workspace support prevents extension from recognizing files outside workspace Jun 26, 2019
@brettcannon brettcannon added this to the 2019 - June Sprint 13 milestone Jun 26, 2019
@kimadeline
Copy link

@DonJayamanne Can you make this an official ask for the VS Code team?

@kimadeline kimadeline self-assigned this Oct 10, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Oct 10, 2019
@kimadeline kimadeline removed their assignment Oct 22, 2019
@luabud
Copy link
Member

luabud commented Dec 30, 2019

We should spike on this: #9328

@ErwanDL
Copy link

ErwanDL commented Mar 25, 2020

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.

@jakebailey
Copy link
Member Author

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.

@kcajf
Copy link

kcajf commented Jun 8, 2020

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.

@lihuanshuai
Copy link

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

@ErwanDL
Copy link

ErwanDL commented Jul 17, 2020

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.

@karrtikr
Copy link

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

@jakebailey
Copy link
Member Author

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

@karrtikr karrtikr added this to the October 2021 milestone Oct 22, 2021
@karrtikr karrtikr added the verified Verification succeeded label Oct 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug investigating We are looking into the cause of the issue verified Verification succeeded
Projects
None yet
Development

No branches or pull requests