Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ protected async Task HandleLaunchRequest(
if (this.editorSession.PowerShellContext.CurrentRunspace.Location == RunspaceLocation.Local &&
!this.editorSession.DebugService.IsDebuggerStopped)
{
await editorSession.PowerShellContext.SetWorkingDirectory(workingDir);
await editorSession.PowerShellContext.SetWorkingDirectory(workingDir, isPathAlreadyEscaped: false);
Logger.Write(LogLevel.Verbose, "Working dir set to: " + workingDir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ protected async Task HandleInitializeRequest(
if (editorSession.Workspace.WorkspacePath != null)
{
await editorSession.PowerShellContext.SetWorkingDirectory(
editorSession.Workspace.WorkspacePath);
editorSession.Workspace.WorkspacePath,
isPathAlreadyEscaped: false);
}

await requestContext.SendResult(
Expand Down
15 changes: 15 additions & 0 deletions src/PowerShellEditorServices/Session/PowerShellContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,11 +1078,26 @@ internal void ReleaseRunspaceHandle(RunspaceHandle runspaceHandle)
/// </summary>
/// <param name="path"></param>
public async Task SetWorkingDirectory(string path)
{
await this.SetWorkingDirectory(path, true);
}

/// <summary>
/// Sets the current working directory of the powershell context.
/// </summary>
/// <param name="path"></param>
/// <param name="isPathAlreadyEscaped">Specify false to have the path escaped, otherwise specify true if the path has already been escaped.</param>
public async Task SetWorkingDirectory(string path, bool isPathAlreadyEscaped)
{
this.InitialWorkingDirectory = path;

using (RunspaceHandle runspaceHandle = await this.GetRunspaceHandle())
{
if (!isPathAlreadyEscaped)
{
path = EscapePath(path, false);
}

runspaceHandle.Runspace.SessionStateProxy.Path.SetLocation(path);
}
}
Expand Down