From 38c85bea2753e5c661878e33d29c58d70408f483 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 5 Apr 2017 17:47:36 -0700 Subject: [PATCH] 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. --- src/features/DebugSession.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/features/DebugSession.ts b/src/features/DebugSession.ts index 1da3ff44bd..a95839eb60 100644 --- a/src/features/DebugSession.ts +++ b/src/features/DebugSession.ts @@ -42,7 +42,7 @@ export class DebugSessionFeature implements IFeature { if (config.request === 'launch') { // Make sure there's a usable working directory if possible - config.cwd = config.cwd || vscode.workspace.rootPath || config.script; + config.cwd = config.cwd || vscode.workspace.rootPath; // For launch of "current script", don't start the debugger if the current file // is not a file that can be debugged by PowerShell @@ -80,6 +80,12 @@ export class DebugSessionFeature implements IFeature { } } } + else if (config.script) { + // In this case, the user has explicitly defined a script path + // so make sure to set the cwd to that path if the cwd wasn't + // explicitly set + config.cwd = config.cwd || config.script; + } } // Prevent the Debug Console from opening