Skip to content

Commit 885dcab

Browse files
authored
Merge pull request PowerShell#431 from daviwil/fix-vsc-632
Fix debugger startup hang when session still initializing
2 parents f862b8c + 160c2d1 commit 885dcab

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ protected async Task HandleLaunchRequest(
273273
// TODO: What's the right approach here?
274274
if (this.editorSession.PowerShellContext.CurrentRunspace.Location == RunspaceLocation.Local)
275275
{
276-
editorSession.PowerShellContext.SetWorkingDirectory(workingDir);
276+
await editorSession.PowerShellContext.SetWorkingDirectory(workingDir);
277277
Logger.Write(LogLevel.Verbose, "Working dir set to: " + workingDir);
278278
}
279279

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ protected async Task HandleInitializeRequest(
183183
// Set the working directory of the PowerShell session to the workspace path
184184
if (editorSession.Workspace.WorkspacePath != null)
185185
{
186-
editorSession.PowerShellContext.SetWorkingDirectory(
186+
await editorSession.PowerShellContext.SetWorkingDirectory(
187187
editorSession.Workspace.WorkspacePath);
188188
}
189189

src/PowerShellEditorServices/Session/PowerShellContext.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1048,9 +1048,12 @@ internal void ReleaseRunspaceHandle(RunspaceHandle runspaceHandle)
10481048
/// unescaped before calling this method.
10491049
/// </summary>
10501050
/// <param name="path"></param>
1051-
public void SetWorkingDirectory(string path)
1051+
public async Task SetWorkingDirectory(string path)
10521052
{
1053-
this.CurrentRunspace.Runspace.SessionStateProxy.Path.SetLocation(path);
1053+
using (RunspaceHandle runspaceHandle = await this.GetRunspaceHandle())
1054+
{
1055+
runspaceHandle.Runspace.SessionStateProxy.Path.SetLocation(path);
1056+
}
10541057
}
10551058

10561059
/// <summary>

0 commit comments

Comments
 (0)