MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / closeNotebooks

Function closeNotebooks

src/test/datascience/notebook/helper.ts:387–422  ·  view source on GitHub ↗
(disposables: IDisposable[] = [])

Source from the content-addressed store, hash-verified

385}
386
387export async function closeNotebooks(disposables: IDisposable[] = []) {
388 if (!isInsiders()) {
389 return false;
390 }
391 logger.debug(
392 `Before Closing all notebooks, currently opened ${workspace.notebookDocuments
393 .map((item) => getDisplayPath(item.uri))
394 .join(', ')}`
395 );
396 await initialize();
397 VSCodeNotebookController.kernelAssociatedWithDocument = undefined;
398 // We could have untitled notebooks, close them by reverting changes.
399 // eslint-disable-next-line @typescript-eslint/no-explicit-any
400 const documents = new Set<NotebookDocument>(workspace.notebookDocuments);
401 while (window.activeNotebookEditor) {
402 documents.add(window.activeNotebookEditor.notebook);
403 await commands.executeCommand('workbench.action.revertAndCloseActiveEditor');
404 await sleep(10);
405 }
406
407 // That command does not cause notebook on close to fire. Fire this for every active editor
408 // documents.forEach((d) => this._onDidCloseNotebookDocument.fire(d));
409
410 await closeActiveWindows();
411 dispose(disposables);
412 await shutdownAllNotebooks();
413 if (workspace.notebookDocuments.length) {
414 logger.debug(
415 `After Closing all notebooks, currently opened ${workspace.notebookDocuments
416 .map((item) => getDisplayPath(item.uri))
417 .join(', ')}`
418 );
419 } else {
420 logger.debug(`Closed all notebooks`);
421 }
422}
423
424let waitForKernelPendingPromise: Promise<void> | undefined;
425

Calls 12

isInsidersFunction · 0.90
getDisplayPathFunction · 0.90
initializeFunction · 0.90
sleepFunction · 0.90
closeActiveWindowsFunction · 0.90
disposeFunction · 0.90
shutdownAllNotebooksFunction · 0.85
joinMethod · 0.80
mapMethod · 0.80
debugMethod · 0.65
addMethod · 0.65
executeCommandMethod · 0.65

Tested by

no test coverage detected