mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 17:19:01 +01:00
💂 notebook tab switching and pick editor types.
This commit is contained in:
@@ -319,6 +319,70 @@ suite('notebook working copy', () => {
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
|
||||
test('multiple tabs: dirty + clean', async function () {
|
||||
const resource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './first.vsctestnb'));
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
await waitFor(500);
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.source, '');
|
||||
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
|
||||
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
|
||||
|
||||
const secondResource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './second.vsctestnb'));
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
await waitFor(500);
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
|
||||
// make sure that the previous dirty editor is still restored in the extension host and no data loss
|
||||
assert.equal(vscode.notebook.activeNotebookEditor !== undefined, true);
|
||||
assert.equal(vscode.notebook.activeNotebookEditor?.selection !== undefined, true);
|
||||
assert.deepEqual(vscode.notebook.activeNotebookEditor?.document.cells[1], vscode.notebook.activeNotebookEditor?.selection);
|
||||
assert.deepEqual(vscode.notebook.activeNotebookEditor?.document.cells.length, 3);
|
||||
assert.equal(vscode.notebook.activeNotebookEditor?.selection?.source, 'var abc = 0;');
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
|
||||
test('multiple tabs: two dirty tabs and switching', async function () {
|
||||
const resource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './first.vsctestnb'));
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
await waitFor(500);
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.source, '');
|
||||
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellAbove');
|
||||
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
|
||||
|
||||
const secondResource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './second.vsctestnb'));
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
await waitFor(500);
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.source, '');
|
||||
|
||||
// switch to the first editor
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor !== undefined, true);
|
||||
assert.equal(vscode.notebook.activeNotebookEditor?.selection !== undefined, true);
|
||||
assert.deepEqual(vscode.notebook.activeNotebookEditor?.document.cells[1], vscode.notebook.activeNotebookEditor?.selection);
|
||||
assert.deepEqual(vscode.notebook.activeNotebookEditor?.document.cells.length, 3);
|
||||
assert.equal(vscode.notebook.activeNotebookEditor?.selection?.source, 'var abc = 0;');
|
||||
|
||||
// switch to the second editor
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor !== undefined, true);
|
||||
assert.equal(vscode.notebook.activeNotebookEditor?.selection !== undefined, true);
|
||||
assert.deepEqual(vscode.notebook.activeNotebookEditor?.document.cells[1], vscode.notebook.activeNotebookEditor?.selection);
|
||||
assert.deepEqual(vscode.notebook.activeNotebookEditor?.document.cells.length, 2);
|
||||
assert.equal(vscode.notebook.activeNotebookEditor?.selection?.source, '');
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.saveAll');
|
||||
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
|
||||
});
|
||||
});
|
||||
|
||||
suite('metadata', () => {
|
||||
@@ -344,6 +408,25 @@ suite('regression', () => {
|
||||
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.source, '');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.language, 'typescript');
|
||||
});
|
||||
|
||||
test('#97830, #97764. Support switch to other editor types', async function () {
|
||||
const resource = vscode.Uri.parse(join(vscode.workspace.rootPath || '', './empty.vsctestnb'));
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
await waitFor(500);
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
|
||||
await vscode.commands.executeCommand('default:type', { text: 'var abc = 0;' });
|
||||
|
||||
assert.equal(vscode.notebook.activeNotebookEditor !== undefined, true, 'notebook first');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.source, 'var abc = 0;');
|
||||
assert.equal(vscode.notebook.activeNotebookEditor!.selection?.language, 'typescript');
|
||||
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'default');
|
||||
assert.equal(vscode.window.activeTextEditor?.document.uri.path, resource.path);
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.saveAll');
|
||||
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
|
||||
});
|
||||
});
|
||||
|
||||
suite('webview resource uri', () => {
|
||||
|
||||
Reference in New Issue
Block a user