astral-sh/ruff-vscode

Unnecessary Error modal when deleting cell in Jupyter Notebook

theelderbeever opened this issue · 2 comments

Reproduce

No code necessary.

  1. Turn on Ruff: Native Server
  2. Create a Jupyter Notebook in VS Code (need jupyter extension).
  3. Create a new cell by tapping b
  4. Now delete the cell with dd

A modal will pop up for Ruff encountered a problem. Check the logs for more details.

Ruff Output

2024-06-11 08:20:46.737 [info] 371.956068s ERROR ruff_server::server::api An error occurred while running textDocument/didClose: Unable to take snapshot for document with URL vscode-notebook-cell:/path/to/notebook/ruff.ipynb#W1sZmlsZQ%3D%3D

Info

VS Code Extension: v2024.26.0
Ruff: 0.4.8

Expectation

Modal is unnecessary and provides no added value.

The issue here is that notebookDocument/didChange is sent before document/didClose, which means that the notebook cell is de-registered and the cell URI is no longer valid. I think the way around this is to defer removing the cell from the index until didClose.