-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make middleware wait for connection #17879
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
Make middleware wait for connection #17879
Conversation
} | ||
} | ||
|
||
public resolveCompletionItem(): ProviderResult<CompletionItem> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there any reason to remove the return type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the others do, it seems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that I didn't have to rewrite it as Promise. It's inferred from the other call so we don't really need it.
@@ -0,0 +1 @@ | |||
Semantic colorization can sometimes require reopening or scrolling of a file. No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an odd changelog item; does this fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The root cause was the provideDocumentSemanticTokens override I added for notebooks. If connected was false, the token request would return null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only ask because I think most changelog items say something like "Fixed bug ..." or something.
public provideHover() { | ||
if (this.connected) { | ||
public async provideHover() { | ||
if (await this.connected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do some methods await connected, while some just call callNext
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ones that don't await connected don't return promises. They can't await. And they should honestly go through before connection anyway.
@jakebailey did you have any more comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, though I haven't personally built and tested this PR with Pylance.
I still don't understand why you need to do all of this in the middleware. Shouldn't this be the responsibility of the server since the server knows which state it has to reach to correctly answer a request. |
The server doesn't know what the interpreter selected in VS code is. It's waiting for that to be computed. |
Further, no Python LS has knowledge of notebooks (interpreter is one aspect, but on the whole, we don't know how to piece together cells or anything), so this is all required to let the Jupyter extension and such deal with triaging requests to handle them correctly. Our intent is that all of this code gets dropped as we work to shift notebook support down the stack into Pylance. |
I like this since it is the right approach. Would be cool if the Python extension talks to the Pylance extension using our command based language API (see https://code.visualstudio.com/api/references/commands) |
This is actually where I was starting (using commands) (example: there's no LSP message for notebook cells moving around). Good to know that you agree :) |
Fixes #17878
We can't skip token requests just because the python interpreter isn't set yet in pylance. Instead we should wait for the interpreter to be set.