-
Notifications
You must be signed in to change notification settings - Fork 511
Allow user to customize the working dir that the debugger starts in #88
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
Allow user to customize the working dir that the debugger starts in #88
Comments
Can we add |
Yes. That's what I was going to do after the PSES side PR got merged. That is what both the mono-debug and node-debug packages do.
Good question. That was the way I was previously going to implement it (and what you get if VSCode passes cwd = null) except that it gets the directory of launchParams.Program (which defaults to ${file}). Hmm, but the user can override Program in their launch.json file so if the user wanted this behavior all they (or we by default) need to do is set cwd to null. Cool. So how should be initialize cwd by default? ${workspaceRoot} or null? |
I'd say try it with null first to see if it does in fact set the current working directory to the script's path. Since we're auto-executing the currently opened script in the debugger now, I think it'd make more sense if the cwd was the script's path rather than the workspace path. Users who know they need the workspacePath set instead will figure out how to set it. |
Will do. |
OK so neither |
Sounds good! That may require another change in the PR we just merged in Editor Services, though. I think we need to call |
Err, to be more specific, we need to call |
Heheh, yup working on that. Here is what I have: // Set the working directory for the PowerShell runspace to something reasonable
// such as the cwd passed in via launch.json. And in case that is null, use the
// the folder of the script to be executed. If cwd is a file path then extract the
// directory and use that.
string workingDir = launchParams.Cwd ?? launchParams.Program;
try
{
if ((File.GetAttributes(workingDir) & FileAttributes.Directory) != FileAttributes.Directory)
{
workingDir = Path.GetDirectoryName(workingDir);
}
}
catch (Exception ex)
{
Logger.Write(LogLevel.Error, "cwd path is bad: " + ex.Message);
}
var setWorkingDirCommand = new PSCommand();
setWorkingDirCommand.AddCommand(@"Microsoft.PowerShell.Management\Set-Location")
.AddParameter("LiteralPath", workingDir);
await editorSession.PowerShellContext.ExecuteCommand(setWorkingDirCommand); Note that I can't seem to set a default cwd value of |
Yep, sounds fine. New changes look good! |
Fixes #88 by adding cwd initialConfig and configProps to package.json
Technically you can do this without any change to the package.json file but without
cwd
being defined in theconfigurationProperties
, VSCode will whine when you edit a launch.json file and add the property.The text was updated successfully, but these errors were encountered: