Skip to content

Commit 7f6d285

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 PowerShell#655.
1 parent cf95f1b commit 7f6d285

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/features/DebugSession.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ 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 =
46+
config.cwd ||
47+
vscode.workspace.rootPath ||
48+
(!currentDocument.isUntitled ? config.script : undefined);
4649

4750
// For launch of "current script", don't start the debugger if the current file
4851
// is not a file that can be debugged by PowerShell
@@ -51,6 +54,7 @@ export class DebugSessionFeature implements IFeature {
5154
if (currentDocument.isUntitled) {
5255
if (currentDocument.languageId === 'powershell') {
5356
config.script = currentDocument.uri.toString();
57+
config.cwd = vscode.workspace.rootPath;
5458
}
5559
else {
5660
let msg = "To debug '" + currentDocument.fileName +

0 commit comments

Comments
 (0)