Closed ashep closed 4 years ago
Hi there! Any information about this issue? Thank you in advance.
I've had to move back to jedi due to this behavior.
@CodeMonk, thank you for the suggestion. I'm going to try it in the nearest future. Can you tell me what's in your opinion is better: using Jedi or not?
After watching the OP's video, I'm not sure that it's the LS that's the problem here. We have no control over the UI, but the actual context menu items are disappearing, which is very strange. Is the original workspace multi-root?
@jakebailey, yes, it is multi-root.
This makes sense (in a way). You're jumping out to something outside the workspace, so the editor doesn't know which running language server to send the requests to, which is microsoft/vscode-python#5132. However, it shouldn't completely fail afterwards.
If you use a single root, this will probably go away, as now there's only a single LS running and all Python-related requests go to the same place.
@jakebailey, thank you, I'll try in a few days and report about results.
That makes sense (multi-root discussion). I do run python from a pyenv for my django development. And, I do occasionally open files from outside of my repo / .pyenv
@ashep Wrote
@CodeMonk, thank you for the suggestion. I'm going to try it in the nearest future. Can you tell me what's in your opinion is better: using Jedi or not?
I've used Jedi a lot in neovim, during the slow days, so, I'm not a real fan of jedi. And, the language server used to work REALLY well, even finding references from deep inside of libraries.
So, I guess I'm of the opinion that you should use jedi, if it works for you, until they fix the python language server. Least, that's what I'm going to do.
Note that in this instance, I don't even think switching analyzers will help, as the extension is going to spawn multiple things for multiple workspaces anyway, the oddity is in the behavior of VS Code, not any one analyzer (which all feed back to the same APIs).
@CodeMonk If there's something wrong with references deep inside libraries, that'd be something to report (or point to the issue you mean if it's already reported). #840 covers where we don't allow some features outside of user code, but bugs for things past that would be valuable to know.
Sorry - I should have been more clear:
Given the discussion above, I assumed that the failure(s) were related to the language server not using the .pyenv correctly after the multi-root changes.
I do not know of any strange behaviors other than Go to Definition
not working unless you use jedi instead of the Microsoft Python Language Server.
So, using jedi also disables the ability to search for a symbol in workspace. I am NOT running multi-root, but, I do have a django app.
If you have an issue with Jedi in the VS Code extension, I suggest asking on the extension's issue tracker. Jedi/MPLS are mutually exclusive, and the extension must provide all of the info Jedi cannot separately.
That was simply a data point for whoever is looking into the issue.
Works:
Broken:
I never suggested that this issue was tasked with fixing anything in Jedi. I simply pointed out, more specifically, what things work and do not work for me.
It seems switching to single-root workspace helped.
My workspace is not multi-root . . . that I know of. There is only one directory in Project Manager plugin's config.
Soooo - things are now working for me with the ms python language server. I have recreated my .pyenv, and I've also rebooted . . . . very strange.
I'll try to grab logs if I see it failing again, using the developer console
The developer console is the editor/extension and wouldn't contain stuff related to the language server itself (maybe some info about how they are handling our responses). You may or may not find something interesting there.
AFAIK this is still the same behavior as microsoft/vscode-python#5132, the overall issue with the way VS Code handles LSP requests to multiple language servers in multiple workspaces. Even if it's a single workspace, if the UI elements disappear then it could only be the extension or the editor itself causing the issue, as we have no control over what is shown in the UI; we declare that we support go-to-def and it's up to the client to send us a request.
@jakebailey I want to confirm that I understand the vscode-python issue.
I generally run a vscode session in a django directory with an activated .pyenv virtualenv. Things work great, and I do not do multi-root workspaces.
However, I may open a file outside of my workspace with code
but, those files are generally not related to my workspace.
I also, rarely, rebuild my .pyenv.
Could either of the above actions cause the language server to fail? And, once it has failed, is there a way to fix it? Restarting vscode has not helped in the past, but, I'm not 100% certain that I've actually restarted, and didn't have something keeping it from exiting completely (another window, etc)
If something
can repair the broken server, I wouldn't mind doing it occasionally until the multi-root issues are fixed. (i.e. restarting vscode, restarting it from a new activated shell, etc)
So in general, the language server will throw away information about libraries to save memory. This means that the moment you leave your workspace and enter a file that's not "your code", the language server will fail to perform certain operations that have been dropped out of memory. This is expected behavior. #840
Also expected right now due to microsoft/vscode-python#5132 is that a multi-root workspace will not show any UI elements at all for features outside the workspace. To support multi-root workspaces and multiple LSs, the extension tells the editor "the python files within this directory go to this language server". This means that if a file is outside of those roots, then the editor will not tell any language server about the file and no functionality will work.
What's not expected is go-to-def-ing into a library file, it breaking, then coming back to the user code and it remaining broken. Your code in a workspace should always remain working.
"python.analysis.openFilesOnly": false,
"python.analysis.memory.keepLibraryAst": true,
"python.analysis.memory.keepLibraryLocalVariables": true,
These settings not work for me.
Process, close, Microsoft.Python.LanguageServer.exe
I run this autohotkey to kill LS process, waiting for it auto restart and goto works...
Making it (#840) work may require #1861.
We'll see if this helps this specific case.
I traced this down; it's a bug in the extension around multi-root workspace support. I'll close this in favor of microsoft/vscode-python#11317 as I don't think we can do anything here.
Environment data
"python.jediEnabled"
set to; more info microsoft/vscode-python#3977): Falsepython.languageServer
setting: MicrosoftExpected behaviour
"Go to definition" functionality doesn't stop working.
Actual behaviour
"Go to definition" functionality stops working.
Steps to reproduce:
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)https://www.dropbox.com/s/luc53x67qtfibcm/1582172224580.log?dl=0