ruff/crates
Dhruv Manilawala 7910beecc4
Consider the content of the new cells during notebook sync (#12203)
## Summary

This PR fixes the bug where the server was not considering the
`cells.structure.didOpen` field to sync up the new content of the newly
added cells.

The parameters corresponding to this request provides two fields to get
the newly added cells:
1. `cells.structure.array.cells`: This is a list of `NotebookCell` which
doesn't contain any cell content. The only useful information from this
array is the cell kind and the cell document URI which we use to
initialize the new cell in the index.
2. `cells.structure.didOpen`: This is a list of `TextDocumentItem` which
corresponds to the newly added cells. This actually contains the text
content and the version.

This wasn't a problem before because we initialize the cell with an
empty string and this isn't a problem when someone just creates an empty
cell. But, when someone copy-pastes a cell, the cell needs to be
initialized with the content.

fixes: #12201 

## Test Plan

First, let's see the panic in action:

1. Press <kbd>Esc</kbd> to allow using the keyboard to perform cell
actions (move around, copy, paste, etc.)
2. Copy the second cell with <kbd>c</kbd> key
3. Delete the second cell with <kbd>dd</kbd> key
4. Paste the copied cell with <kbd>p</kbd> key

You can see that the content isn't synced up because the `unused-import`
for `sys` is still being highlighted but it's being used in the second
cell. And, the hover isn't working either. Then, as I start editing the
second cell, it panics.


fc58364c-c8fc-4c11-a917-71b6dd90c1ef

Now, here's the preview of the fixed version:


207872dd-dca6-49ee-8b6e-80435c7ef22e
2024-07-05 17:10:00 +05:30
..
red_knot [red-knot] Add very basic benchmark (#12182) 2024-07-04 15:29:00 +00:00
red_knot_module_resolver [red-knot] Migrate CLI to Salsa (#11972) 2024-07-04 07:23:45 +00:00
red_knot_python_semantic [red-knot] Migrate CLI to Salsa (#11972) 2024-07-04 07:23:45 +00:00
ruff Revert "Remove --preview as a required argument for ruff server (#12053)" (#12196) 2024-07-05 11:58:35 +05:30
ruff_benchmark [red-knot] Add very basic benchmark (#12182) 2024-07-04 15:29:00 +00:00
ruff_cache Fix cache key collisions for paths with separators (#12159) 2024-07-03 07:36:46 -05:00
ruff_db [red-knot] Add very basic benchmark (#12182) 2024-07-04 15:29:00 +00:00
ruff_dev Drop deprecated nursery rule group (#10172) 2024-06-27 13:44:11 +02:00
ruff_diagnostics Move sub-crates to workspace dependencies (#11407) 2024-05-13 14:37:50 +00:00
ruff_formatter Fix formatter instability for lines only consisting of zero-width characters (#11748) 2024-06-05 17:55:14 +02:00
ruff_index Red-knot: Track scopes per expression (#11754) 2024-06-05 17:53:26 +02:00
ruff_linter [pycodestyle] Whitespace after decorator (E204) (#12140) 2024-07-04 23:31:03 +00:00
ruff_macros Drop deprecated nursery rule group (#10172) 2024-06-27 13:44:11 +02:00
ruff_notebook Add Jupyter Notebook document change snapshot test (#11944) 2024-06-21 05:29:27 +00:00
ruff_python_ast Use CompactString for Identifier (#12101) 2024-07-01 10:06:02 +02:00
ruff_python_ast_integration_tests Rename PreorderVisitor to SourceOrderVisitor (#11798) 2024-06-07 17:01:58 +00:00
ruff_python_codegen Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_formatter Update Rust crate rustc-hash to v2 (#12001) 2024-06-23 20:46:42 -04:00
ruff_python_index Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_literal Remove some unused pub functions (#11576) 2024-05-28 09:56:51 -04:00
ruff_python_parser Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_resolver chore(deps): update rust crate insta to v1.38.0 (#10701) 2024-04-01 15:44:30 +00:00
ruff_python_semantic Use CompactString for Identifier (#12101) 2024-07-01 10:06:02 +02:00
ruff_python_stdlib Regenerate sys.rs with stdlibs==2024.5.15 (#11437) 2024-05-15 22:17:32 +00:00
ruff_python_trivia Mention that Cursor is based on rustc's implementation. (#12109) 2024-06-30 16:53:25 +01:00
ruff_python_trivia_integration_tests Build CommentRanges outside the parser (#11792) 2024-06-09 09:55:17 +00:00
ruff_server Consider the content of the new cells during notebook sync (#12203) 2024-07-05 17:10:00 +05:30
ruff_source_file red-knot: source_text, line_index, and parsed_module queries (#11822) 2024-06-13 07:37:02 +00:00
ruff_text_size Upgrade to Rust 1.79 (#11875) 2024-06-17 07:15:10 +01:00
ruff_wasm Show syntax errors on the playground (#12083) 2024-06-28 13:06:15 +05:30
ruff_workspace docs(options): fix some typos and improve consistency (#12191) 2024-07-04 19:05:03 -04:00