Consider the content of the new cells during notebook sync #12203
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
cells.structure.array.cells
: This is a list ofNotebookCell
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.cells.structure.didOpen
: This is a list ofTextDocumentItem
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:
You can see that the content isn't synced up because the
unused-import
forsys
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.Screen.Recording.2024-07-05.at.16.49.09.mov
Now, here's the preview of the fixed version:
Screen.Recording.2024-07-05.at.16.49.39.mov