chore(vscode): update to 1.53.2
These conflicts will be resolved in the following commits. We do it this way so that PR review is possible.
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const path = require('path');
|
||||
const testRunner = require('vscode/lib/testrunner');
|
||||
const testRunner = require('../../../test/integration/electron/testrunner');
|
||||
|
||||
const options: any = {
|
||||
ui: 'tdd',
|
||||
|
@ -935,6 +935,108 @@ suite('notebook workflow', () => {
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
|
||||
test('cell execute command takes arguments', async () => {
|
||||
assertInitalState();
|
||||
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
|
||||
const editor = vscode.window.activeNotebookEditor!;
|
||||
const cell = editor.document.cells[0];
|
||||
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.equal(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
|
||||
const metadataChangeEvent = getEventOncePromise<vscode.NotebookDocumentMetadataChangeEvent>(vscode.notebook.onDidChangeNotebookDocumentMetadata);
|
||||
editor.document.metadata.runnable = true;
|
||||
await metadataChangeEvent;
|
||||
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
|
||||
const clearChangeEvent = getEventOncePromise<vscode.NotebookDocumentMetadataChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
await clearChangeEvent;
|
||||
assert.equal(cell.outputs.length, 0, 'should clear');
|
||||
|
||||
const secondResource = await createRandomFile('', undefined, 'second', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
await vscode.commands.executeCommand('notebook.cell.execute', { start: 0, end: 1 }, resource);
|
||||
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.equal(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
|
||||
test('document execute command takes arguments', async () => {
|
||||
assertInitalState();
|
||||
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
|
||||
const editor = vscode.window.activeNotebookEditor!;
|
||||
const cell = editor.document.cells[0];
|
||||
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.equal(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
|
||||
const metadataChangeEvent = getEventOncePromise<vscode.NotebookDocumentMetadataChangeEvent>(vscode.notebook.onDidChangeNotebookDocumentMetadata);
|
||||
editor.document.metadata.runnable = true;
|
||||
await metadataChangeEvent;
|
||||
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
|
||||
const clearChangeEvent = getEventOncePromise<vscode.NotebookDocumentMetadataChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
await clearChangeEvent;
|
||||
assert.equal(cell.outputs.length, 0, 'should clear');
|
||||
|
||||
const secondResource = await createRandomFile('', undefined, 'second', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
await vscode.commands.executeCommand('notebook.execute', resource);
|
||||
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.equal(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
|
||||
test('cell execute and select kernel', async () => {
|
||||
assertInitalState();
|
||||
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
assert.equal(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first');
|
||||
const editor = vscode.window.activeNotebookEditor!;
|
||||
const cell = editor.document.cells[0];
|
||||
|
||||
const metadataChangeEvent = getEventOncePromise<vscode.NotebookDocumentMetadataChangeEvent>(vscode.notebook.onDidChangeNotebookDocumentMetadata);
|
||||
editor.document.metadata.runnable = true;
|
||||
await metadataChangeEvent;
|
||||
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.deepEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
|
||||
'text/plain': [
|
||||
'my output'
|
||||
]
|
||||
});
|
||||
|
||||
await vscode.commands.executeCommand('notebook.selectKernel', { extension: 'vscode.vscode-notebook-tests', id: 'secondaryKernel' })
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
assert.equal(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.deepEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
|
||||
'text/plain': [
|
||||
'my second output'
|
||||
]
|
||||
});
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
});
|
||||
|
||||
suite('notebook dirty state', () => {
|
||||
@ -1269,11 +1371,10 @@ suite('regression', () => {
|
||||
await vscode.commands.executeCommand('vscode.open', cell.uri, vscode.ViewColumn.Active);
|
||||
|
||||
assert.strictEqual(!!vscode.window.activeNotebookEditor, true);
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.toString(), resource.toString());
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor!.document.uri.toString(), resource.toString());
|
||||
});
|
||||
|
||||
test('Cannot open notebook from cell-uri with vscode.open-command', async function () {
|
||||
this.skip();
|
||||
test.skip('Cannot open notebook from cell-uri with vscode.open-command', async function () {
|
||||
assertInitalState();
|
||||
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
@ -1288,7 +1389,7 @@ suite('regression', () => {
|
||||
// removes the fragment if it matches something numeric. For notebooks that's not wanted...
|
||||
await vscode.commands.executeCommand('vscode.open', cell.uri);
|
||||
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.toString(), resource.toString());
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor!.document.uri.toString(), resource.toString());
|
||||
});
|
||||
|
||||
test('#97830, #97764. Support switch to other editor types', async function () {
|
||||
|
@ -60,6 +60,7 @@ export function activate(context: vscode.ExtensionContext): any {
|
||||
}));
|
||||
|
||||
const kernel: vscode.NotebookKernel = {
|
||||
id: 'mainKernel',
|
||||
label: 'Notebook Test Kernel',
|
||||
isPreferred: true,
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
@ -118,9 +119,69 @@ export function activate(context: vscode.ExtensionContext): any {
|
||||
cancelCellExecution: async (_document: vscode.NotebookDocument, _cell: vscode.NotebookCell) => { }
|
||||
};
|
||||
|
||||
const kernel2: vscode.NotebookKernel = {
|
||||
id: 'secondaryKernel',
|
||||
label: 'Notebook Secondary Test Kernel',
|
||||
isPreferred: false,
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const cell = _document.cells[0];
|
||||
|
||||
cell.outputs = [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my second output']
|
||||
}
|
||||
}];
|
||||
return;
|
||||
},
|
||||
cancelAllCellsExecution: async (_document: vscode.NotebookDocument) => { },
|
||||
executeCell: async (document: vscode.NotebookDocument, cell: vscode.NotebookCell | undefined) => {
|
||||
if (!cell) {
|
||||
cell = document.cells[0];
|
||||
}
|
||||
|
||||
if (document.uri.path.endsWith('customRenderer.vsctestnb')) {
|
||||
cell.outputs = [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/custom': 'test 2'
|
||||
}
|
||||
}];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const previousOutputs = cell.outputs;
|
||||
const newOutputs: vscode.CellOutput[] = [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my second output']
|
||||
}
|
||||
}];
|
||||
|
||||
cell.outputs = newOutputs;
|
||||
|
||||
_onDidChangeNotebook.fire({
|
||||
document: document,
|
||||
undo: () => {
|
||||
if (cell) {
|
||||
cell.outputs = previousOutputs;
|
||||
}
|
||||
},
|
||||
redo: () => {
|
||||
if (cell) {
|
||||
cell.outputs = newOutputs;
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
},
|
||||
cancelCellExecution: async (_document: vscode.NotebookDocument, _cell: vscode.NotebookCell) => { }
|
||||
};
|
||||
|
||||
context.subscriptions.push(vscode.notebook.registerNotebookKernelProvider({ filenamePattern: '*.vsctestnb' }, {
|
||||
provideKernels: async () => {
|
||||
return [kernel];
|
||||
return [kernel, kernel2];
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user