Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/core/src/test/testUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,30 +490,30 @@ export async function closeAllEditors(): Promise<void> {
/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')}`)
}
}
Expand Down
Loading