Open krassowski opened 1 year ago
This results in a new connection being opened on every keypress within the nested documents.
It is quite hard to resolve here, as all the problematic logic is upstream, but does upstream even want transclusions? The overrides were removed but extractors were retained, so I got mixed messages.
And, this also breaks diagnostics in nested documents because by the time the diagnostics response arrives the ID of virtual document has changed. only related to standalone documents
There is a partial workaround I included earlier, but this only prevents infinite loops, not replacement of virtual document connections:
It is quite hard to resolve here, as all the problematic logic is upstream, but does upstream even want transclusions? The overrides were removed but extractors were retained, so I got mixed messages.
IIRC we decided to drop the transclusion via magics but keep supporting the LSP for different cell types, that's why the extractors were kept.
I agree this issue needs to be solved, because if I want to have different cells to have different language support inside the python notebook, I need to have standalone virtual documents for each cell respectively (specific use case is that I can have sql cells and python cells at the same time inside the notebook). Now this is an issue in JL4, which was not happening in JL3. As shown in the screenshot every keystroke opens a new connection if I specify standalone as true and causes infinitely duplicated lsp connection to the same cells.
Standalone documents represent fragments of code which are independent of any preceding and following code. An example in IPython is (each block represents a cell):
There used to be a logic for reusing connections for standalone documents, which greatly improved performance (without it LSP becomes unavailable in the standalone document for 1-2 seconds while a new connection is established; it also risks saturating the number of websockets etc)
https://github.com/jupyter-lsp/jupyterlab-lsp/blob/ff8b6c44d5a81a7bc051604ea37a5bc4da6ec94a/packages/jupyterlab-lsp/src/virtual/document.ts#L477-L503
This was removed when the code was moved upstream to
@jupyterlab/lsp
- it is no longer inchooseForeignDocument
. The removal was not complete asunusedStandaloneDocuments
was retained, even though it is no longer populated.It might be possible to monkeypatch the
VirtualDocument
downstream to restore this logic, or to restore this upstream but it might benefit from a larger refactor as arguably it was not very well written (it should be a responsibility of connection manager, not virtual document).Before I start working on it I would like ask for some community support to indicate whether there is a need for this - if you are using this extension in JupyterLab 4.0 and are affected by the performance in standalone documents, please leave a comment/upvote.