use vscode.notebooks not vscode.notebook
This commit is contained in:
parent
a3337d01bb
commit
b5bdc48d55
2 changed files with 30 additions and 30 deletions
|
@ -255,7 +255,7 @@ suite('Notebook Document', function () {
|
|||
value: 'new_code'
|
||||
}]);
|
||||
|
||||
const event = utils.asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
const event = utils.asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebooks.onDidChangeNotebookCells);
|
||||
|
||||
const success = await vscode.workspace.applyEdit(edit);
|
||||
assert.strictEqual(success, true);
|
||||
|
|
|
@ -272,7 +272,7 @@ suite('Notebook API tests', function () {
|
|||
const resource = await createRandomNotebookFile();
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebooks.onDidChangeNotebookCells);
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
|
||||
const cellChangeEventRet = await cellsChangeEvent;
|
||||
assert.strictEqual(cellChangeEventRet.document, vscode.window.activeNotebookEditor?.document);
|
||||
|
@ -286,11 +286,11 @@ suite('Notebook API tests', function () {
|
|||
]
|
||||
});
|
||||
|
||||
const moveCellEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
const moveCellEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebooks.onDidChangeNotebookCells);
|
||||
await vscode.commands.executeCommand('notebook.cell.moveUp');
|
||||
await moveCellEvent;
|
||||
|
||||
const cellOutputChange = asPromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
const cellOutputChange = asPromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
const cellOutputsAddedRet = await cellOutputChange;
|
||||
assert.deepStrictEqual(cellOutputsAddedRet, {
|
||||
|
@ -299,7 +299,7 @@ suite('Notebook API tests', function () {
|
|||
});
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 1);
|
||||
|
||||
const cellOutputClear = asPromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
const cellOutputClear = asPromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
const cellOutputsCleardRet = await cellOutputClear;
|
||||
assert.deepStrictEqual(cellOutputsCleardRet, {
|
||||
|
@ -308,7 +308,7 @@ suite('Notebook API tests', function () {
|
|||
});
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 0);
|
||||
|
||||
// const cellChangeLanguage = getEventOncePromise<vscode.NotebookCellLanguageChangeEvent>(vscode.notebook.onDidChangeCellLanguage);
|
||||
// const cellChangeLanguage = getEventOncePromise<vscode.NotebookCellLanguageChangeEvent>(vscode.notebooks.onDidChangeCellLanguage);
|
||||
// await vscode.commands.executeCommand('notebook.cell.changeToMarkdown');
|
||||
// const cellChangeLanguageRet = await cellChangeLanguage;
|
||||
// assert.deepStrictEqual(cellChangeLanguageRet, {
|
||||
|
@ -327,7 +327,7 @@ suite('Notebook API tests', function () {
|
|||
|
||||
const activeCell = getFocusedCell(vscode.window.activeNotebookEditor);
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor!.document.getCells().indexOf(activeCell!), 0);
|
||||
const moveChange = asPromise(vscode.notebook.onDidChangeNotebookCells);
|
||||
const moveChange = asPromise(vscode.notebooks.onDidChangeNotebookCells);
|
||||
await vscode.commands.executeCommand('notebook.cell.moveDown');
|
||||
await moveChange;
|
||||
await saveAllEditors();
|
||||
|
@ -399,7 +399,7 @@ suite('Notebook API tests', function () {
|
|||
const resource = await createRandomNotebookFile();
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
const event = asPromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebook.onDidChangeCellMetadata);
|
||||
const event = asPromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebooks.onDidChangeCellMetadata);
|
||||
|
||||
await vscode.window.activeNotebookEditor!.edit(editBuilder => {
|
||||
editBuilder.replaceCellMetadata(0, { inputCollapsed: true });
|
||||
|
@ -416,8 +416,8 @@ suite('Notebook API tests', function () {
|
|||
const resource = await createRandomNotebookFile();
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
const cellMetadataChangeEvent = asPromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebook.onDidChangeCellMetadata);
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebooks.onDidChangeNotebookCells);
|
||||
const cellMetadataChangeEvent = asPromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebooks.onDidChangeCellMetadata);
|
||||
const version = vscode.window.activeNotebookEditor!.document.version;
|
||||
await vscode.window.activeNotebookEditor!.edit(editBuilder => {
|
||||
editBuilder.replaceCells(1, 0, [{ kind: vscode.NotebookCellKind.Code, languageId: 'javascript', value: 'test 2', outputs: [], metadata: undefined }]);
|
||||
|
@ -433,8 +433,8 @@ suite('Notebook API tests', function () {
|
|||
const resource = await createRandomNotebookFile();
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
const cellMetadataChangeEvent = asPromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebook.onDidChangeCellMetadata);
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebooks.onDidChangeNotebookCells);
|
||||
const cellMetadataChangeEvent = asPromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebooks.onDidChangeCellMetadata);
|
||||
const version = vscode.window.activeNotebookEditor!.document.version;
|
||||
await vscode.window.activeNotebookEditor!.edit(editBuilder => {
|
||||
editBuilder.replaceCells(1, 0, [{ kind: vscode.NotebookCellKind.Code, languageId: 'javascript', value: 'test 2', outputs: [], metadata: undefined }]);
|
||||
|
@ -457,7 +457,7 @@ suite('Notebook API tests', function () {
|
|||
const resource = await createRandomNotebookFile();
|
||||
let count = 0;
|
||||
|
||||
testDisposables.push(vscode.notebook.onDidChangeNotebookCells(() => {
|
||||
testDisposables.push(vscode.notebooks.onDidChangeNotebookCells(() => {
|
||||
count++;
|
||||
}));
|
||||
|
||||
|
@ -585,7 +585,7 @@ suite('Notebook API tests', function () {
|
|||
edit.insert(getFocusedCell(vscode.window.activeNotebookEditor)!.document.uri, new vscode.Position(0, 0), 'var abc = 0;');
|
||||
await vscode.workspace.applyEdit(edit);
|
||||
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebooks.onDidChangeNotebookCells);
|
||||
await vscode.commands.executeCommand('notebook.cell.joinAbove');
|
||||
await cellsChangeEvent;
|
||||
|
||||
|
@ -626,7 +626,7 @@ suite('Notebook API tests', function () {
|
|||
|
||||
// currentKernelProvider.setHasKernels(true);
|
||||
|
||||
// await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
// await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
// await vscode.commands.executeCommand('notebook.execute');
|
||||
// await event;
|
||||
// assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
|
@ -655,13 +655,13 @@ suite('Notebook API tests', function () {
|
|||
const editor = vscode.window.activeNotebookEditor!;
|
||||
const cell = editor.document.cellAt(0);
|
||||
|
||||
await withEvent(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
});
|
||||
|
||||
await withEvent(vscode.notebook.onDidChangeCellOutputs, async event => {
|
||||
await withEvent(vscode.notebooks.onDidChangeCellOutputs, async event => {
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 0, 'should clear');
|
||||
|
@ -670,7 +670,7 @@ suite('Notebook API tests', function () {
|
|||
const secondResource = await createRandomNotebookFile();
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.cell.execute', { start: 0, end: 1 }, resource);
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
|
@ -687,7 +687,7 @@ suite('Notebook API tests', function () {
|
|||
let secondCellExecuted = false;
|
||||
let resolve: () => void;
|
||||
const p = new Promise<void>(r => resolve = r);
|
||||
const listener = vscode.notebook.onDidChangeCellOutputs(e => {
|
||||
const listener = vscode.notebooks.onDidChangeCellOutputs(e => {
|
||||
e.cells.forEach(cell => {
|
||||
if (cell.index === 0) {
|
||||
firstCellExecuted = true;
|
||||
|
@ -715,13 +715,13 @@ suite('Notebook API tests', function () {
|
|||
const editor = vscode.window.activeNotebookEditor!;
|
||||
const cell = editor.document.cellAt(0);
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
});
|
||||
|
||||
const clearChangeEvent = asPromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
const clearChangeEvent = asPromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
await clearChangeEvent;
|
||||
assert.strictEqual(cell.outputs.length, 0, 'should clear');
|
||||
|
@ -729,7 +729,7 @@ suite('Notebook API tests', function () {
|
|||
const secondResource = await createRandomNotebookFile();
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.execute', resource);
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
|
@ -744,7 +744,7 @@ suite('Notebook API tests', function () {
|
|||
|
||||
const cell = editor.document.cellAt(0);
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await assertKernel(kernel1, notebook);
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
await event;
|
||||
|
@ -754,7 +754,7 @@ suite('Notebook API tests', function () {
|
|||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].items[0].data), 'my output');
|
||||
});
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await assertKernel(kernel2, notebook);
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
await event;
|
||||
|
@ -792,7 +792,7 @@ suite('Notebook API tests', function () {
|
|||
const editor = await vscode.window.showNotebookDocument(notebook);
|
||||
const cell = editor.document.cellAt(0);
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await assertKernel(cancelableKernel, notebook);
|
||||
assert.ok(editor === vscode.window.activeNotebookEditor);
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
|
@ -834,7 +834,7 @@ suite('Notebook API tests', function () {
|
|||
const editor = await vscode.window.showNotebookDocument(notebook);
|
||||
const cell = editor.document.cellAt(0);
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebooks.onDidChangeCellOutputs, async (event) => {
|
||||
await assertKernel(interruptableKernel, notebook);
|
||||
assert.ok(editor === vscode.window.activeNotebookEditor);
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
|
@ -859,7 +859,7 @@ suite('Notebook API tests', function () {
|
|||
let eventCount = 0;
|
||||
let resolve: () => void;
|
||||
const p = new Promise<void>(r => resolve = r);
|
||||
const listener = vscode.notebook.onDidChangeNotebookCellExecutionState(e => {
|
||||
const listener = vscode.notebooks.onDidChangeNotebookCellExecutionState(e => {
|
||||
if (eventCount === 0) {
|
||||
assert.strictEqual(e.state, vscode.NotebookCellExecutionState.Pending, 'should be set to Pending');
|
||||
} else if (eventCount === 1) {
|
||||
|
@ -1152,7 +1152,7 @@ suite('Notebook API tests', function () {
|
|||
const notebook = await vscode.workspace.openNotebookDocument(resource);
|
||||
const editor = await vscode.window.showNotebookDocument(notebook);
|
||||
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
const cellsChangeEvent = asPromise<vscode.NotebookCellsChangeEvent>(vscode.notebooks.onDidChangeNotebookCells);
|
||||
await editor.edit(editBuilder => {
|
||||
editBuilder.replaceCells(1, 0, [{ kind: vscode.NotebookCellKind.Code, languageId: 'javascript', value: 'test 2', outputs: [], metadata: undefined }]);
|
||||
});
|
||||
|
@ -1161,7 +1161,7 @@ suite('Notebook API tests', function () {
|
|||
assert.strictEqual(cellChangeEventRet.document === notebook, true);
|
||||
assert.strictEqual(cellChangeEventRet.document.isDirty, true);
|
||||
|
||||
const saveEvent = asPromise(vscode.notebook.onDidSaveNotebookDocument);
|
||||
const saveEvent = asPromise(vscode.notebooks.onDidSaveNotebookDocument);
|
||||
|
||||
await notebook.save();
|
||||
|
||||
|
@ -1233,7 +1233,7 @@ suite('Notebook API tests', function () {
|
|||
const emitter = new vscode.EventEmitter<vscode.NotebookCell>();
|
||||
const onDidCallProvide = emitter.event;
|
||||
suiteSetup(() => {
|
||||
vscode.notebook.registerNotebookCellStatusBarItemProvider('notebookCoreTest', {
|
||||
vscode.notebooks.registerNotebookCellStatusBarItemProvider('notebookCoreTest', {
|
||||
async provideCellStatusBarItems(cell: vscode.NotebookCell, _token: vscode.CancellationToken): Promise<vscode.NotebookCellStatusBarItem[]> {
|
||||
emitter.fire(cell);
|
||||
return [];
|
||||
|
|
Loading…
Reference in a new issue