diff --git a/src/features/PesterTests.ts b/src/features/PesterTests.ts index bd11d319eb..0486c7323a 100644 --- a/src/features/PesterTests.ts +++ b/src/features/PesterTests.ts @@ -144,6 +144,6 @@ export class PesterTestsFeature implements vscode.Disposable { // Ensure the necessary script exists (for testing). The debugger will // start regardless, but we also pass its success along. return utils.fileExists(this.invokePesterStubScriptPath) - && vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], launchConfig); + && vscode.debug.startDebugging(vscode.workspace.workspaceFolders?.[0], launchConfig); } } diff --git a/src/features/RunCode.ts b/src/features/RunCode.ts index 72cda68976..288a7b1295 100644 --- a/src/features/RunCode.ts +++ b/src/features/RunCode.ts @@ -49,7 +49,7 @@ export class RunCodeFeature implements vscode.Disposable { this.sessionManager.getSessionDetails()); // TODO: Update to handle multiple root workspaces. - vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], launchConfig); + vscode.debug.startDebugging(vscode.workspace.workspaceFolders?.[0], launchConfig); } }