diff --git a/packages/core/src/test/testUtil.ts b/packages/core/src/test/testUtil.ts index d45a0b1ad20..eac5ffc2a2b 100644 --- a/packages/core/src/test/testUtil.ts +++ b/packages/core/src/test/testUtil.ts @@ -490,30 +490,30 @@ export async function closeAllEditors(): Promise { /amazonwebservices\.[a-z\-]+-vscode\./, /nullExtensionDescription./, // Sometimes exists instead of the prior line, see https://github.com/aws/aws-toolkit-vscode/issues/4658 ] - const editors: vscode.TextEditor[] = [] + const editorsToClose: vscode.TextEditor[] = [] const noVisibleEditor: boolean | undefined = await waitUntil( async () => { // Race: documents could appear after the call to closeAllEditors(), so retry. await vscode.commands.executeCommand(closeAllCmd) - editors.length = 0 - editors.push( + editorsToClose.length = 0 + editorsToClose.push( ...vscode.window.visibleTextEditors.filter( (editor) => !ignorePatterns.some((p) => p.test(editor.document.fileName)) ) ) - return editors.length === 0 + return editorsToClose.length === 0 }, { - timeout: 5000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. + timeout: 1000, // Arbitrary values. Should succeed except when VS Code is lagging heavily. interval: 250, truthy: true, } ) - if (!noVisibleEditor) { - const editorNames = editors.map((editor) => `\t${editor.document.fileName}`) + if (!noVisibleEditor && editorsToClose.length > 0) { + const editorNames = editorsToClose.map((editor) => `\t${editor.document.fileName}`) throw new Error(`Editors were still open after closeAllEditors():\n${editorNames.join('\n')}`) } }