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

Function closeWindowsAndNotebooks

src/test/initialize.ts:42–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 await closeWindowsAndNotebooks();
41}
42async function closeWindowsAndNotebooks(): Promise<void> {
43 if (!isInsiders() || !isANotebookOpen()) {
44 await closeWindowsInternal();
45 return;
46 }
47 // We could have untitled notebooks, close them by reverting changes.
48 // eslint-disable-next-line @typescript-eslint/no-explicit-any
49 while (vscode.window.activeNotebookEditor || vscode.window.activeTextEditor) {
50 await vscode.commands.executeCommand('workbench.action.revertAndCloseActiveEditor');
51 }
52 // Work around VS Code issues (sometimes notebooks do not get closed).
53 // Hence keep trying.
54 for (let counter = 0; counter <= 5 && isANotebookOpen(); counter += 1) {
55 await sleep(counter * 10);
56 await closeWindowsInternal();
57 }
58}
59
60async function closeWindowsInternal() {
61 // If there are no editors, we can skip. This seems to time out if no editors visible.

Callers 1

closeActiveWindowsFunction · 0.85

Calls 5

sleepFunction · 0.90
isInsidersFunction · 0.85
isANotebookOpenFunction · 0.85
closeWindowsInternalFunction · 0.85
executeCommandMethod · 0.65

Tested by

no test coverage detected