mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-19 16:18:58 +01:00
change cell language with cell change events.
This commit is contained in:
@@ -135,7 +135,7 @@ suite('Notebook API tests', function () {
|
||||
id: 'mainKernel',
|
||||
label: 'Notebook Test Kernel',
|
||||
isPreferred: true,
|
||||
supportedLanguages: ['typescript'],
|
||||
supportedLanguages: ['typescript', 'javascript'],
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
|
||||
@@ -174,7 +174,7 @@ suite('Notebook API tests', function () {
|
||||
id: 'secondaryKernel',
|
||||
label: 'Notebook Secondary Test Kernel',
|
||||
isPreferred: false,
|
||||
supportedLanguages: ['typescript'],
|
||||
supportedLanguages: ['typescript', 'javascript'],
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookCellOutput(_document.uri, 0, [new vscode.NotebookCellOutput([
|
||||
@@ -471,6 +471,30 @@ suite('Notebook API tests', function () {
|
||||
await saveFileAndCloseAll(resource);
|
||||
});
|
||||
|
||||
test('change cell language', async function () {
|
||||
assertInitalState();
|
||||
const resource = await createRandomFile('', undefined, '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.cells[0].language, 'typescript');
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.cells[0].cellKind, vscode.NotebookCellKind.Code);
|
||||
await withEvent(vscode.notebook.onDidChangeCellLanguage, async event => {
|
||||
await vscode.commands.executeCommand('notebook.cell.changeLanguage', { start: 0, end: 1 }, 'javascript');
|
||||
await event;
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.cells[0].language, 'javascript');
|
||||
});
|
||||
|
||||
// switch to markdown will change the cell kind
|
||||
await withEvent(vscode.notebook.onDidChangeNotebookCells, async event => {
|
||||
await vscode.commands.executeCommand('notebook.cell.changeLanguage', { start: 0, end: 1 }, 'markdown');
|
||||
await event;
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.cells[0].language, 'markdown');
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.cells[0].cellKind, vscode.NotebookCellKind.Markdown);
|
||||
});
|
||||
|
||||
await saveAllFilesAndCloseAll(resource);
|
||||
});
|
||||
|
||||
test('edit API (replaceCells)', async function () {
|
||||
assertInitalState();
|
||||
const resource = await createRandomFile('', undefined, '.vsctestnb');
|
||||
|
||||
Reference in New Issue
Block a user