Skip to content
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

ruff server: Defer notebook cell deletion to avoid an error message #11864

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

snowsignal
Copy link
Contributor

Summary

Fixes astral-sh/ruff-vscode#496.

Cells are no longer removed from the notebook index when a notebook gets updated, but rather when textDocument/didClose is called for them. This solves an issue where their premature removal from the notebook cell index would cause their URL to be un-queryable in the textDocument/didClose handler.

Test Plan

Create and then delete a notebook cell in VS Code. No error should appear.

@snowsignal snowsignal added the server Related to the LSP server label Jun 13, 2024
Copy link
Contributor

github-actions bot commented Jun 13, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser
Copy link
Member

Any chance that this solves #11851

@T-256
Copy link
Contributor

T-256 commented Jun 14, 2024

Any chance that this solves #11851

Created #11867 for that. According to this message's log it seems he was got multiple error on closing a notebook document with multiple cells in it.

@MichaReiser
Copy link
Member

Reading through the comments, I think the change makes sense. However, I would find it helpful if we can expand the comment explaining how cells are closed now with an explanation on how VS code handles it. I think that would also be helpful for someone coming back to this PR to understand why and what has changed.

@snowsignal snowsignal enabled auto-merge (squash) June 18, 2024 03:34
@snowsignal snowsignal merged commit ffc9852 into main Jun 18, 2024
17 of 18 checks passed
@snowsignal snowsignal deleted the jane/server/defer-cell-index-deletion branch June 18, 2024 03:37
Copy link

codspeed-hq bot commented Jun 18, 2024

CodSpeed Performance Report

Merging #11864 will degrade performances by 9.48%

Comparing jane/server/defer-cell-index-deletion (9c4abdb) with jane/server/defer-cell-index-deletion (dd865d0)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 28 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark jane/server/defer-cell-index-deletion jane/server/defer-cell-index-deletion Change
linter/all-rules[numpy/globals.py] 701.9 µs 775.5 µs -9.48%
parser[pydantic/types.py] 2.2 ms 2.1 ms +4.26%

dhruvmanila added a commit that referenced this pull request Jul 30, 2024
## Summary

This PR fixes a bug where the server wouldn't retain the cell content in
case of a reorder change request.

As mentioned in
#12573 (comment),
this change request is modeled as (a) remove these cell URIs and (b) add
these cell URIs. The cell content isn't provided. But, the way we've
modeled the `NotebookCell` (it contains the underlying `TextDocument`),
we need to keep track of the deleted cells to get the content.

This is not an ideal solution and a better long term solution would be
to model it as per the spec but that is a big structural change and will
affect multiple parts of the server. Modeling as per the spec would also
avoid bugs like #11864. For
context, that model would add complexity per
#11206 (comment).

fixes: #12573

## Test Plan

This video shows the before and after the bug is fixed:


https://github.com/user-attachments/assets/2fcad4b5-f9af-4776-8640-4cd1fa16e325
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Related to the LSP server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary Error modal when deleting cell in Jupyter Notebook
4 participants