Skip to content

Support debugging without a workspace #3728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2021
Merged

Conversation

andyleejordan
Copy link
Member

The existing code assumed there was always at least one workspace folder, but this led to an error if there were zero. This can be reproduced by calling "Close Workspace" if one is open and then running Pester tests. Since the vscode.debug.startDebugging() interface does not require a workspace folder, and in fact expects "undefined" if none is available, we simply use TypeScript's "optional chaining" (AKA conditional access) operator to return undefined if workspaceFolders is null, and otherwise return the first workspace folder.

Fixes #3713.

The existing code assumed there was always at least one workspace
folder, but this led to an error if there were zero. This can be
reproduced by calling "Close Workspace" if one is open and then running
Pester tests. Since the `vscode.debug.startDebugging()` interface does
not require a workspace folder, and in fact expects "undefined" if none
is available, we simply use TypeScript's "optional chaining" (AKA
conditional access) operator to return undefined if `workspaceFolders`
is null, and otherwise return the first workspace folder.
@andyleejordan andyleejordan merged commit 63bbb2f into master Dec 17, 2021
@andyleejordan andyleejordan deleted the andschwa/no-workspace branch December 17, 2021 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Running any pester tests shows Cannot read property '0' of undefined
2 participants