(disposables: IDisposable[] = [])
| 385 | } |
| 386 | |
| 387 | export 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 | |
| 424 | let waitForKernelPendingPromise: Promise<void> | undefined; |
| 425 |
no test coverage detected