mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Option in showNotebook to open as REPL (#225273)
* new API option and flag * show the notebook as a repl * handle any notebook type, dispose all model refs * open notebook doc as scratchpad * delay loading the model for untitled notebooks until shown * add initial content consistently for untitled * simplify utitled notebook creation * recover open untitled notebook as dirty behavior
This commit is contained in:
@@ -18,6 +18,10 @@ async function openRandomNotebookDocument() {
|
||||
return vscode.workspace.openNotebookDocument(uri);
|
||||
}
|
||||
|
||||
async function openUntitledNotebookDocument(data?: vscode.NotebookData) {
|
||||
return vscode.workspace.openNotebookDocument('notebookCoreTest', data);
|
||||
}
|
||||
|
||||
export async function saveAllFilesAndCloseAll() {
|
||||
await saveAllEditors();
|
||||
await closeAllEditors();
|
||||
@@ -188,6 +192,27 @@ const apiTestSerializer: vscode.NotebookSerializer = {
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor!.notebook.uri.toString(), document.uri.toString());
|
||||
});
|
||||
|
||||
test('Opening an utitled notebook without content will only open the editor when shown.', async function () {
|
||||
const document = await openUntitledNotebookDocument();
|
||||
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor, undefined);
|
||||
|
||||
// opening a cell-uri opens a notebook editor
|
||||
await vscode.window.showNotebookDocument(document);
|
||||
|
||||
assert.strictEqual(!!vscode.window.activeNotebookEditor, true);
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor!.notebook.uri.toString(), document.uri.toString());
|
||||
});
|
||||
|
||||
test('Opening an untitled notebook with content will open a dirty document.', async function () {
|
||||
const language = 'python';
|
||||
const cell = new vscode.NotebookCellData(vscode.NotebookCellKind.Code, '', language);
|
||||
const data = new vscode.NotebookData([cell]);
|
||||
const doc = await vscode.workspace.openNotebookDocument('jupyter-notebook', data);
|
||||
|
||||
assert.strictEqual(doc.isDirty, true);
|
||||
});
|
||||
|
||||
test('Cannot open notebook from cell-uri with vscode.open-command', async function () {
|
||||
|
||||
const document = await openRandomNotebookDocument();
|
||||
|
||||
Reference in New Issue
Block a user