Skip to content

Commit 38c85be

Browse files
committed
Fix issue with cwd being set to untitled file path
This change fixes an issue with untitled file paths being sent in the cwd parameter to debug adapter when in a window that doesn't have a workspace loaded. The fix is to change our cwd selection logic to be more aware of an untitled file being used. Resolves #655.
1 parent cf95f1b commit 38c85be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/features/DebugSession.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class DebugSessionFeature implements IFeature {
4242

4343
if (config.request === 'launch') {
4444
// Make sure there's a usable working directory if possible
45-
config.cwd = config.cwd || vscode.workspace.rootPath || config.script;
45+
config.cwd = config.cwd || vscode.workspace.rootPath;
4646

4747
// For launch of "current script", don't start the debugger if the current file
4848
// is not a file that can be debugged by PowerShell
@@ -80,6 +80,12 @@ export class DebugSessionFeature implements IFeature {
8080
}
8181
}
8282
}
83+
else if (config.script) {
84+
// In this case, the user has explicitly defined a script path
85+
// so make sure to set the cwd to that path if the cwd wasn't
86+
// explicitly set
87+
config.cwd = config.cwd || config.script;
88+
}
8389
}
8490

8591
// Prevent the Debug Console from opening

0 commit comments

Comments
 (0)