Skip to content

Conversation

rchiodo
Copy link

@rchiodo rchiodo commented Oct 29, 2021

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.

@rchiodo rchiodo added the skip tests Updates to tests unnecessary label Oct 29, 2021
@rchiodo rchiodo added the skip package*.json package.json and package-lock.json don't both need updating label Oct 29, 2021
}
}

public resolveCompletionItem(): ProviderResult<CompletionItem> {
Copy link
Member

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?

Copy link
Member

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.

Copy link
Author

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
Copy link
Member

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?

Copy link
Author

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

Copy link
Member

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) {
Copy link
Member

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?

Copy link
Author

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.

@rchiodo
Copy link
Author

rchiodo commented Oct 29, 2021

@jakebailey did you have any more comments?

Copy link
Member

@jakebailey jakebailey left a 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.

@rchiodo rchiodo merged commit 9bf27f2 into microsoft:main Oct 29, 2021
@dbaeumer
Copy link
Member

dbaeumer commented Nov 1, 2021

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.

@rchiodo
Copy link
Author

rchiodo commented Nov 1, 2021

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.

@rchiodo rchiodo deleted the rchiodo/await_connect_middleware branch November 1, 2021 16:04
@jakebailey
Copy link
Member

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.

@dbaeumer
Copy link
Member

dbaeumer commented Nov 8, 2021

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)

@rchiodo
Copy link
Author

rchiodo commented Nov 8, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Semantic highlighting does not work if registered after file is open

5 participants