Skip to content

Commit 19a13d9

Browse files
committed
Fix missing prompt when launching temporary interactive debug session
This change fixes an issue which causes the command prompt to not appear when you start an interactive debugging session with the -DebugServiceOnly parameter. The fix is to invoke the host's command loop in this specific case. Resolves PowerShell/vscode-powershell#942
1 parent 40b1cb4 commit 19a13d9

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/PowerShellEditorServices.Host/EditorServicesHost.cs

+1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ private EditorSession CreateDebugSession(
407407

408408
editorSession.StartDebugSession(
409409
powerShellContext,
410+
hostUserInterface,
410411
editorOperations);
411412

412413
return editorSession;

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

+17-8
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,23 @@ protected async Task HandleConfigurationDoneRequest(
217217

218218
await requestContext.SendResult(null);
219219

220-
if (this.isInteractiveDebugSession &&
221-
this.editorSession.DebugService.IsDebuggerStopped)
220+
if (this.isInteractiveDebugSession)
222221
{
223-
// If this is an interactive session and there's a pending breakpoint,
224-
// send that information along to the debugger client
225-
this.DebugService_DebuggerStopped(
226-
this,
227-
this.editorSession.DebugService.CurrentDebuggerStoppedEventArgs);
222+
if (this.ownsEditorSession)
223+
{
224+
// If this is a debug-only session, we need to start
225+
// the command loop manually
226+
this.editorSession.HostInput.StartCommandLoop();
227+
}
228+
229+
if (this.editorSession.DebugService.IsDebuggerStopped)
230+
{
231+
// If this is an interactive session and there's a pending breakpoint,
232+
// send that information along to the debugger client
233+
this.DebugService_DebuggerStopped(
234+
this,
235+
this.editorSession.DebugService.CurrentDebuggerStoppedEventArgs);
236+
}
228237
}
229238
}
230239

@@ -646,7 +655,7 @@ protected async Task HandleStackTraceRequest(
646655
int startFrameIndex = stackTraceParams.StartFrame ?? 0;
647656
int maxFrameCount = stackFrames.Length;
648657

649-
// If the number of requested levels == 0 (or null), that means get all stack frames
658+
// If the number of requested levels == 0 (or null), that means get all stack frames
650659
// after the specified startFrame index. Otherwise get all the stack frames.
651660
int requestedFrameCount = (stackTraceParams.Levels ?? 0);
652661
if (requestedFrameCount > 0)

src/PowerShellEditorServices/Session/EditorSession.cs

+3
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,17 @@ public void StartSession(
123123
/// for the ConsoleService.
124124
/// </summary>
125125
/// <param name="powerShellContext"></param>
126+
/// <param name="hostInput"></param>
126127
/// <param name="editorOperations">
127128
/// An IEditorOperations implementation used to interact with the editor.
128129
/// </param>
129130
public void StartDebugSession(
130131
PowerShellContext powerShellContext,
132+
IHostInput hostInput,
131133
IEditorOperations editorOperations)
132134
{
133135
this.PowerShellContext = powerShellContext;
136+
this.HostInput = hostInput;
134137

135138
// Initialize all services
136139
this.RemoteFileManager = new RemoteFileManager(this.PowerShellContext, editorOperations, logger);

0 commit comments

Comments
 (0)