()
| 40 | await closeWindowsAndNotebooks(); |
| 41 | } |
| 42 | async 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 | |
| 60 | async function closeWindowsInternal() { |
| 61 | // If there are no editors, we can skip. This seems to time out if no editors visible. |
no test coverage detected