Hi
Thanks for maintaining this library. We're trying to upgrade Ruff's and ty's LSP to the new language client v10, but are running into challenges with the new notebook pull diagnostic support.
Problem
A cell move changes the order of notebook cells without changing their text or
their document URIs. Cell order can change the diagnostics of any cell, but the
diagnostic client does not request new diagnostics after this structural change.
Moving a cell sends the following notebookDocument/didChange notification, but
the diagnostic client does not pull diagnostics after this structural change:
{
"cells": {
"structure": {
"array": {
"start": 0,
"deleteCount": 2,
"cells": ["existing-cell-b", "existing-cell-a"]
},
"didOpen": [],
"didClose": []
}
}
}
The diagnostic feature handles cells.textContent, structure.didOpen, and
structure.didClose, but ignores changes to structure.array itself. Although
the diagnostic provider explicitly advertises interFileDependencies: true, a
pure structural reorder neither pulls any cell directly nor triggers the
background dependency scheduler. Existing diagnostics therefore remain stale
indefinitely after the move (unless the LSP works around this)
Minimal reproduction
First enable the dependency capability in
client-node-tests/src/servers/fullNotebookServer.ts:
diagnosticProvider: {
identifier: 'diagnostic-provider',
documentSelector: null,
- interFileDependencies: false,
+ interFileDependencies: true,
workspaceDiagnostics: false
}
Then add this test to the existing suite('Full notebook tests', ...) in
client-node-tests/src/integration.test.ts:
test('Notebook cell reorder refreshes pulled diagnostics', async () => {
const notebook = await vscode.workspace.openNotebookDocument(
'jupyter-notebook',
new vscode.NotebookData([
new vscode.NotebookCellData(vscode.NotebookCellKind.Code, 'use(value)', 'python'),
new vscode.NotebookCellData(vscode.NotebookCellKind.Code, 'value = 1', 'python'),
]),
);
const firstCellUri = notebook.cellAt(0).document.uri;
await client.sendNotification(SetDiagnosticsNotification.method, {
uri: firstCellUri.toString(),
report: {
kind: 'full',
resultId: 'before-reorder',
items: [{
message: 'cell order diagnostic',
range: {
start: { line: 0, character: 0 },
end: { line: 0, character: 3 },
},
}],
},
});
const editor = await vscode.window.showNotebookDocument(notebook);
for (let attempt = 0; attempt < 50; attempt++) {
if (vscode.languages.getDiagnostics(firstCellUri).length === 1) {
break;
}
await new Promise<void>((resolve) => setTimeout(resolve, 20));
}
assert.strictEqual(vscode.languages.getDiagnostics(firstCellUri).length, 1);
// The mock server now has the result expected after the cells are reordered.
// It will return this result if the client requests fresh diagnostics.
await client.sendNotification(SetDiagnosticsNotification.method, {
uri: firstCellUri.toString(),
report: {
kind: 'full',
resultId: 'after-reorder',
items: [],
},
});
const pulledAfterReorder: string[] = [];
client.middleware.provideDiagnostics = async (document, previousResultId, token, next) => {
const uri = document instanceof vscode.Uri ? document : document.uri;
pulledAfterReorder.push(uri.toString());
return next(document, previousResultId, token);
};
try {
editor.selection = new vscode.NotebookRange(0, 1);
await vscode.commands.executeCommand('notebook.cell.moveDown');
assert.strictEqual(notebook.cellAt(1).document.uri.toString(), firstCellUri.toString());
await new Promise<void>((resolve) => setTimeout(resolve, 750));
assert.ok(
pulledAfterReorder.length > 0,
'Reordering existing notebook cells should trigger diagnostic pulls',
);
assert.strictEqual(vscode.languages.getDiagnostics(firstCellUri).length, 0);
} finally {
client.middleware.provideDiagnostics = undefined;
await revertAllDirty();
}
}).timeout(5000);
Hi
Thanks for maintaining this library. We're trying to upgrade Ruff's and ty's LSP to the new language client v10, but are running into challenges with the new notebook pull diagnostic support.
Problem
A cell move changes the order of notebook cells without changing their text or
their document URIs. Cell order can change the diagnostics of any cell, but the
diagnostic client does not request new diagnostics after this structural change.
Moving a cell sends the following
notebookDocument/didChangenotification, butthe diagnostic client does not pull diagnostics after this structural change:
{ "cells": { "structure": { "array": { "start": 0, "deleteCount": 2, "cells": ["existing-cell-b", "existing-cell-a"] }, "didOpen": [], "didClose": [] } } }The diagnostic feature handles
cells.textContent,structure.didOpen, andstructure.didClose, but ignores changes tostructure.arrayitself. Althoughthe diagnostic provider explicitly advertises
interFileDependencies: true, apure structural reorder neither pulls any cell directly nor triggers the
background dependency scheduler. Existing diagnostics therefore remain stale
indefinitely after the move (unless the LSP works around this)
Minimal reproduction
First enable the dependency capability in
client-node-tests/src/servers/fullNotebookServer.ts:diagnosticProvider: { identifier: 'diagnostic-provider', documentSelector: null, - interFileDependencies: false, + interFileDependencies: true, workspaceDiagnostics: false }Then add this test to the existing
suite('Full notebook tests', ...)inclient-node-tests/src/integration.test.ts: