Skip to content

Commit e614e97

Browse files
authored
SAM debugconfig: look for workspace folder #1143
Problem: > [ERROR]: SAM debug: no workspace folder Analysis: If vscode workspace file exists (example: `.vscode/Untitled.code-workspace`) then: - vscode adds configs to it instead of `.vscode/launch.json`. - `folder` is undefined when VSCode invokes `resolveDebugConfiguration()`. - Workspace folders are available via `vscode.workspace.workspaceFolders[x]`. Solution: - If `folder` is undefined and `vscode.workspace.workspaceFolders.length === 1`, then use `vscode.workspace.workspaceFolders[0]`. - If `vscode.workspace.workspaceFolders.length > 1`, VSCode appears to choose one, and thus `folder` is _not_ undefined when `resolveDebugConfiguration()` is invoked.
1 parent 5a6432e commit e614e97

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/shared/sam/debugger/awsSamDebugger.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ export class SamDebugConfigProvider implements vscode.DebugConfigurationProvider
216216
if (token?.isCancellationRequested) {
217217
return undefined
218218
}
219+
folder =
220+
folder ?? (vscode.workspace.workspaceFolders?.length ? vscode.workspace.workspaceFolders[0] : undefined)
219221
if (!folder) {
220222
getLogger().error(`SAM debug: no workspace folder`)
221223
vscode.window.showErrorMessage(

0 commit comments

Comments
 (0)