File tree 3 files changed +18
-2
lines changed
PowerShellEditorServices/Session
PowerShellEditorServices.Protocol/Server
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -294,7 +294,7 @@ protected async Task HandleLaunchRequest(
294
294
if ( this . editorSession . PowerShellContext . CurrentRunspace . Location == RunspaceLocation . Local &&
295
295
! this . editorSession . DebugService . IsDebuggerStopped )
296
296
{
297
- await editorSession . PowerShellContext . SetWorkingDirectory ( workingDir ) ;
297
+ await editorSession . PowerShellContext . SetWorkingDirectory ( workingDir , isPathAlreadyEscaped : false ) ;
298
298
Logger . Write ( LogLevel . Verbose , "Working dir set to: " + workingDir ) ;
299
299
}
300
300
Original file line number Diff line number Diff line change @@ -178,7 +178,8 @@ protected async Task HandleInitializeRequest(
178
178
if ( editorSession . Workspace . WorkspacePath != null )
179
179
{
180
180
await editorSession . PowerShellContext . SetWorkingDirectory (
181
- editorSession . Workspace . WorkspacePath ) ;
181
+ editorSession . Workspace . WorkspacePath ,
182
+ isPathAlreadyEscaped : false ) ;
182
183
}
183
184
184
185
await requestContext . SendResult (
Original file line number Diff line number Diff line change @@ -1078,11 +1078,26 @@ internal void ReleaseRunspaceHandle(RunspaceHandle runspaceHandle)
1078
1078
/// </summary>
1079
1079
/// <param name="path"></param>
1080
1080
public async Task SetWorkingDirectory ( string path )
1081
+ {
1082
+ await this . SetWorkingDirectory ( path , true ) ;
1083
+ }
1084
+
1085
+ /// <summary>
1086
+ /// Sets the current working directory of the powershell context.
1087
+ /// </summary>
1088
+ /// <param name="path"></param>
1089
+ /// <param name="isPathAlreadyEscaped">Specify false to have the path escaped, otherwise specify true if the path has already been escaped.</param>
1090
+ public async Task SetWorkingDirectory ( string path , bool isPathAlreadyEscaped )
1081
1091
{
1082
1092
this . InitialWorkingDirectory = path ;
1083
1093
1084
1094
using ( RunspaceHandle runspaceHandle = await this . GetRunspaceHandle ( ) )
1085
1095
{
1096
+ if ( ! isPathAlreadyEscaped )
1097
+ {
1098
+ path = EscapePath ( path , false ) ;
1099
+ }
1100
+
1086
1101
runspaceHandle . Runspace . SessionStateProxy . Path . SetLocation ( path ) ;
1087
1102
}
1088
1103
}
You can’t perform that action at this time.
0 commit comments