chore(vscode): update to 1.54.2
This commit is contained in:
@ -11,7 +11,7 @@ function wait(ms: number): Promise<void> {
|
||||
return new Promise(r => setTimeout(r, ms));
|
||||
}
|
||||
|
||||
export function smokeTestActivate(context: vscode.ExtensionContext): any {
|
||||
export function activate(context: vscode.ExtensionContext): any {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-notebook-tests.createNewNotebook', async () => {
|
||||
const workspacePath = vscode.workspace.workspaceFolders![0].uri.fsPath;
|
||||
const notebookPath = path.join(workspacePath, 'test.smoke-nb');
|
||||
@ -21,29 +21,23 @@ export function smokeTestActivate(context: vscode.ExtensionContext): any {
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.notebook.registerNotebookContentProvider('notebookSmokeTest', {
|
||||
onDidChangeNotebook: new vscode.EventEmitter<vscode.NotebookDocumentEditEvent>().event,
|
||||
openNotebook: async (_resource: vscode.Uri) => {
|
||||
const dto: vscode.NotebookData = {
|
||||
languages: ['typescript'],
|
||||
metadata: {},
|
||||
metadata: new vscode.NotebookDocumentMetadata(),
|
||||
cells: [
|
||||
{
|
||||
source: 'code()',
|
||||
language: 'typescript',
|
||||
cellKind: vscode.CellKind.Code,
|
||||
cellKind: vscode.NotebookCellKind.Code,
|
||||
outputs: [],
|
||||
metadata: {
|
||||
custom: { testCellMetadata: 123 }
|
||||
}
|
||||
metadata: new vscode.NotebookCellMetadata().with({ custom: { testCellMetadata: 123 } })
|
||||
},
|
||||
{
|
||||
source: 'Markdown Cell',
|
||||
language: 'markdown',
|
||||
cellKind: vscode.CellKind.Markdown,
|
||||
cellKind: vscode.NotebookCellKind.Markdown,
|
||||
outputs: [],
|
||||
metadata: {
|
||||
custom: { testCellMetadata: 123 }
|
||||
}
|
||||
metadata: new vscode.NotebookCellMetadata().with({ custom: { testCellMetadata: 123 } })
|
||||
}
|
||||
]
|
||||
};
|
||||
@ -71,14 +65,14 @@ export function smokeTestActivate(context: vscode.ExtensionContext): any {
|
||||
label: 'notebookSmokeTest',
|
||||
isPreferred: true,
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
for (let i = 0; i < _document.cells.length; i++) {
|
||||
_document.cells[i].outputs = [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/html': ['test output']
|
||||
}
|
||||
}];
|
||||
edit.replaceNotebookCellOutput(_document.uri, i, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/html', ['test output'], undefined)
|
||||
])]);
|
||||
}
|
||||
|
||||
await vscode.workspace.applyEdit(edit);
|
||||
},
|
||||
cancelAllCellsExecution: async () => { },
|
||||
executeCell: async (_document: vscode.NotebookDocument, _cell: vscode.NotebookCell | undefined) => {
|
||||
@ -86,12 +80,11 @@ export function smokeTestActivate(context: vscode.ExtensionContext): any {
|
||||
_cell = _document.cells[0];
|
||||
}
|
||||
|
||||
_cell.outputs = [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/html': ['test output']
|
||||
}
|
||||
}];
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookCellOutput(_document.uri, _cell.index, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/html', ['test output'], undefined)
|
||||
])]);
|
||||
await vscode.workspace.applyEdit(edit);
|
||||
return;
|
||||
},
|
||||
cancelCellExecution: async () => { }
|
File diff suppressed because it is too large
Load Diff
@ -1,187 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { smokeTestActivate } from './notebookSmokeTestMain';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): any {
|
||||
smokeTestActivate(context);
|
||||
|
||||
const _onDidChangeNotebook = new vscode.EventEmitter<vscode.NotebookDocumentEditEvent | vscode.NotebookDocumentContentChangeEvent>();
|
||||
context.subscriptions.push(_onDidChangeNotebook);
|
||||
context.subscriptions.push(vscode.notebook.registerNotebookContentProvider('notebookCoreTest', {
|
||||
onDidChangeNotebook: _onDidChangeNotebook.event,
|
||||
openNotebook: async (_resource: vscode.Uri) => {
|
||||
if (/.*empty\-.*\.vsctestnb$/.test(_resource.path)) {
|
||||
return {
|
||||
languages: ['typescript'],
|
||||
metadata: {},
|
||||
cells: []
|
||||
};
|
||||
}
|
||||
|
||||
const dto: vscode.NotebookData = {
|
||||
languages: ['typescript'],
|
||||
metadata: {
|
||||
custom: { testMetadata: false }
|
||||
},
|
||||
cells: [
|
||||
{
|
||||
source: 'test',
|
||||
language: 'typescript',
|
||||
cellKind: vscode.CellKind.Code,
|
||||
outputs: [],
|
||||
metadata: {
|
||||
custom: { testCellMetadata: 123 }
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return dto;
|
||||
},
|
||||
resolveNotebook: async (_document: vscode.NotebookDocument) => {
|
||||
return;
|
||||
},
|
||||
saveNotebook: async (_document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) => {
|
||||
return;
|
||||
},
|
||||
saveNotebookAs: async (_targetResource: vscode.Uri, _document: vscode.NotebookDocument, _cancellation: vscode.CancellationToken) => {
|
||||
return;
|
||||
},
|
||||
backupNotebook: async (_document: vscode.NotebookDocument, _context: vscode.NotebookDocumentBackupContext, _cancellation: vscode.CancellationToken) => {
|
||||
return {
|
||||
id: '1',
|
||||
delete: () => { }
|
||||
};
|
||||
}
|
||||
}));
|
||||
|
||||
const kernel: vscode.NotebookKernel = {
|
||||
id: 'mainKernel',
|
||||
label: 'Notebook Test Kernel',
|
||||
isPreferred: true,
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const cell = _document.cells[0];
|
||||
|
||||
cell.outputs = [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my 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'
|
||||
}
|
||||
}];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const previousOutputs = cell.outputs;
|
||||
const newOutputs: vscode.CellOutput[] = [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my 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) => { }
|
||||
};
|
||||
|
||||
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, kernel2];
|
||||
}
|
||||
}));
|
||||
}
|
Reference in New Issue
Block a user