File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
PowerShellEditorServices.Protocol/Server
PowerShellEditorServices/Session Expand file tree Collapse file tree 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(
294294 if ( this . editorSession . PowerShellContext . CurrentRunspace . Location == RunspaceLocation . Local &&
295295 ! this . editorSession . DebugService . IsDebuggerStopped )
296296 {
297- await editorSession . PowerShellContext . SetWorkingDirectory ( workingDir ) ;
297+ await editorSession . PowerShellContext . SetWorkingDirectory ( workingDir , isPathAlreadyEscaped : false ) ;
298298 Logger . Write ( LogLevel . Verbose , "Working dir set to: " + workingDir ) ;
299299 }
300300
Original file line number Diff line number Diff line change @@ -178,7 +178,8 @@ protected async Task HandleInitializeRequest(
178178 if ( editorSession . Workspace . WorkspacePath != null )
179179 {
180180 await editorSession . PowerShellContext . SetWorkingDirectory (
181- editorSession . Workspace . WorkspacePath ) ;
181+ editorSession . Workspace . WorkspacePath ,
182+ isPathAlreadyEscaped : false ) ;
182183 }
183184
184185 await requestContext . SendResult (
Original file line number Diff line number Diff line change @@ -1078,11 +1078,26 @@ internal void ReleaseRunspaceHandle(RunspaceHandle runspaceHandle)
10781078 /// </summary>
10791079 /// <param name="path"></param>
10801080 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 )
10811091 {
10821092 this . InitialWorkingDirectory = path ;
10831093
10841094 using ( RunspaceHandle runspaceHandle = await this . GetRunspaceHandle ( ) )
10851095 {
1096+ if ( ! isPathAlreadyEscaped )
1097+ {
1098+ path = EscapePath ( path , false ) ;
1099+ }
1100+
10861101 runspaceHandle . Runspace . SessionStateProxy . Path . SetLocation ( path ) ;
10871102 }
10881103 }
You can’t perform that action at this time.
0 commit comments