Skip to content

Commit d33a03c

Browse files
Copilotdbaeumer
andauthored
Clarify that notebook cell text sync follows textDocumentSync.change (#2209)
* Initial plan * Add textContentSyncKind to NotebookDocumentSyncOptions for cell text sync negotiation Co-authored-by: dbaeumer <1931590+dbaeumer@users.noreply.github.com> * Document TextDocumentSyncKind.None behavior for cell text synchronization Co-authored-by: dbaeumer <1931590+dbaeumer@users.noreply.github.com> * Document that notebook cell text sync follows textDocumentSync.change Instead of adding a new textContentSyncKind field, clarify in the documentation that notebook cell text documents follow the same synchronization behavior as specified by the server's textDocumentSync.change capability. Co-authored-by: dbaeumer <1931590+dbaeumer@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dbaeumer <1931590+dbaeumer@users.noreply.github.com> Co-authored-by: Dirk Bäumer <dirkb@microsoft.com>
1 parent 0bbb893 commit d33a03c

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

_specifications/lsp/3.17/notebookDocument/notebook.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ The protocol will therefore support two modes when it comes to synchronizing cel
234234
* _cellContent_: in this mode only the cell text content is synchronized to the server using the standard `textDocument/did*` notification. No notebook document and no cell structure is synchronized. This mode allows for easy adoption of notebooks since servers can reuse most of it implementation logic.
235235
* _notebook_: in this mode the notebook document, the notebook cells and the notebook cell text content is synchronized to the server. To allow servers to create a consistent picture of a notebook document the cell text content is NOT synchronized using the standard `textDocument/did*` notifications. It is instead synchronized using special `notebookDocument/did*` notifications. This ensures that the cell and its text content arrives on the server using one open, change or close event.
236236

237+
In both modes, notebook cell text documents are treated as regular text documents. Therefore, they use the same synchronization mechanism as specified by the server's `textDocumentSync` capability. For the _notebook_ mode, the cell text content changes sent via `notebookDocument/didChange` follow the same full/incremental change format as `textDocument/didChange`, respecting the `TextDocumentSyncKind` specified in `textDocumentSync.change`.
238+
237239
To request the cell content only a normal document selector can be used. For example the selector `[{ language: 'python' }]` will synchronize Python notebook document cells to the server. However since this might synchronize unwanted documents as well a document filter can also be a `NotebookCellTextDocumentFilter`. So `{ notebook: { scheme: 'file', notebookType: 'jupyter-notebook' }, language: 'python' }` synchronizes all Python cells in a Jupyter notebook stored on disk.
238240

239241
To synchronize the whole notebook document a server provides a `notebookDocumentSync` in its server capabilities. For example:
@@ -505,6 +507,12 @@ export interface NotebookDocumentChangeEvent {
505507

506508
/**
507509
* Changes to the text content of notebook cells.
510+
*
511+
* Cell text content changes follow the same synchronization mode
512+
* as specified by the server's `textDocumentSync.change` capability.
513+
* If `textDocumentSync.change` is `TextDocumentSyncKind.Incremental`,
514+
* clients should send incremental updates. If it is
515+
* `TextDocumentSyncKind.Full`, clients must send the full content.
508516
*/
509517
textContent?: {
510518
document: VersionedTextDocumentIdentifier;

_specifications/lsp/3.18/notebookDocument/notebook.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ The protocol will therefore support two modes when it comes to synchronizing cel
252252
* _cellContent_: in this mode, only the cell text content is synchronized to the server using the standard `textDocument/did*` notification. No notebook document and no cell structure is synchronized. This mode allows for easy adoption of notebooks since servers can reuse most of their implementation logic.
253253
* _notebook_: in this mode the notebook document, the notebook cells and the notebook cell text content is synchronized to the server. To allow servers to create a consistent picture of a notebook document, the cell text content is NOT synchronized using the standard `textDocument/did*` notifications. It is instead synchronized using special `notebookDocument/did*` notifications. This ensures that the cell and its text content arrive on the server using one open, change or close event.
254254

255+
In both modes, notebook cell text documents are treated as regular text documents. Therefore, they use the same synchronization mechanism as specified by the server's `textDocumentSync` capability. For the _notebook_ mode, the cell text content changes sent via `notebookDocument/didChange` follow the same full/incremental change format as `textDocument/didChange`, respecting the `TextDocumentSyncKind` specified in `textDocumentSync.change`.
256+
255257
To request the cell content, only a normal document selector can be used. For example, the selector `[{ language: 'python' }]` will synchronize Python notebook document cells to the server. However, since this might synchronize unwanted documents as well, a document filter can also be a `NotebookCellTextDocumentFilter`. So `{ notebook: { scheme: 'file', notebookType: 'jupyter-notebook' }, language: 'python' }` synchronizes all Python cells in a Jupyter notebook stored on disk.
256258

257259
To synchronize the whole notebook document, a server provides a `notebookDocumentSync` in its server capabilities. For example:
@@ -523,6 +525,12 @@ export interface NotebookDocumentChangeEvent {
523525

524526
/**
525527
* Changes to the text content of notebook cells.
528+
*
529+
* Cell text content changes follow the same synchronization mode
530+
* as specified by the server's `textDocumentSync.change` capability.
531+
* If `textDocumentSync.change` is `TextDocumentSyncKind.Incremental`,
532+
* clients should send incremental updates. If it is
533+
* `TextDocumentSyncKind.Full`, clients must send the full content.
526534
*/
527535
textContent?: {
528536
document: VersionedTextDocumentIdentifier;

0 commit comments

Comments
 (0)