astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
945 stars 45 forks source link

Unnecessary Error modal when deleting cell in Jupyter Notebook #496

Closed theelderbeever closed 2 weeks ago

theelderbeever commented 3 weeks ago

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.

T-256 commented 3 weeks ago

Related to https://github.com/astral-sh/ruff/issues/11651

snowsignal commented 2 weeks ago

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.