-
Notifications
You must be signed in to change notification settings - Fork 768
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
error squiggle when using %pip
in interactive window
#2894
Comments
We think this may be due to pylance not realizing that the IW input box is part of a "notebook". The "pylance lsp notebooks" setting was on. |
When LSP notebooks are enabled, the Should we be getting a notebookDocument/didOpen instead of a textDocument/didOpen? |
No |
lsp-notebook-concat's Maybe for textDocument/didOpen we should call lsp-notebook-concat's |
@rchiodo, are you planning to have the interactive window be treated as a notebook document from LSP's perspective at some point in the future? I could fix the %magic issue, but that's not the only problem when the LSP notebooks experiment is enabled. Since the interactive window cells are passed as individual text documents, Pylance doesn't chain them together as we do for notebook cells. And therefore IntelliSense, hover, semantic coloring, go to def, etc don't work when working with symbols defined in earlier cells. |
Sounds like a bug in the LSP client if it isn't already behaving this way. With the old middleware solution, the interactive window was treated just like a notebook. I concatenated all of the cells (including the special one at the bottom) into the concatenated document. This would need to happen in the new way too. |
Ok, I'll take a look at the LSP code. Earlier I asked:
And your reply was "No..." so I thought you were saying this was expected at the moment. |
I would expect that the interactive window will have to be treated special in the language client. It's internally a notebook and separate text document, so unless Dirk pieced them together, the language client probably doesn't know about it. |
Is the interactive window a Python-specific feature? I'm wondering if it is generic enough that Dirk would be willing to handle this in vscode-languageclient or if Pylance should special-case it. For IW cells (not the input box), part of the problem in my screenshot above was that Pylance's |
The notebook support in LSP syncs notebooks and not individual cells. Piecing this together might be complicated for me since currently a cell text document is referenced by notebook cell. when syncing things. It sounds like that the interactive windows is visually part of a notebook. Why can't it be a notebook cell as well with a special language id. The you could simply use a special notebook selector (https://github.com/microsoft/vscode-languageserver-node/blob/12900cfb006ce56360e3f64feaeff9c0224854a1/protocol/src/common/protocol.notebook.ts#L312) and everything should work. |
It has a specific scheme associated with it. So I believe if the selector was updated to include the interactive input scheme it might include that document as part of a notebook. Here's the two schemes in use for 'cells' in an interactive window:
The interactive window isn't tied to a specific language (we've just only used it for python so for). |
It's not currently included because cells are expected to have the
To clarify, |
@dbaeumer, here's a picture of the Interactive Window in case you're not familiar with it. When the user clicks the triangular "Execute Code" button to the left of the input box, the text in the input box is removed and placed in a new cell at the bottom of the notebook. |
LSP has no knowledge about the scheme that the editor uses to sync notebooks. Even the VS Code implementations has only little knowledge and mostly only for performance reasons (to not generate unnecessary events). This was done that way since IMO a client shouldn't make any assumption about the cell schema. VS Code should have the freedom to change it. And a server should never ever know which schema an editor uses to identify a notebook cell. The way how LSP communicates with VS Code is basically by using the extended document selector syntax specified via the VS Code API (https://github.com/microsoft/vscode/blob/5bb16df4b0dea028da65676ef28045e70d151157/src/vscode-dts/vscode.d.ts#L2166). To make the interactive Window work I recommend that you use a standard cell and use a special language mode for the interactive cell. Then every code path in VS Code and LSP client / server will work as expected. May I ask how you get that cell with a different schema into the editor in the first place. I was always under the assumption that VS Code manages all these cells? |
VS code does manage the entire interactive window. None of this is created in the extension. It's the one that knows about the schema. We can't change the language as we don't create it. |
OK. Now I see. Then I think either VS Code should use a consistent schema or the schema needs to be handles correctly in the document filter code. |
We're still discussing how to properly fix this, but a temporary workaround will be available in our next release. |
A more correct fix has been checked in and in coming days can be tested with:
|
This issue has been fixed in version 2022.7.42, which we've just released. You can find the changelog here: CHANGELOG.md |
enter
%pip install torch
into the IW input boxThe text was updated successfully, but these errors were encountered: