Skip to content

Commit

Permalink
Fix missing prompt when launching temporary interactive debug session
Browse files Browse the repository at this point in the history
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
  • Loading branch information
daviwil committed Jul 11, 2017
1 parent 40b1cb4 commit 19a13d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/PowerShellEditorServices.Host/EditorServicesHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ private EditorSession CreateDebugSession(

editorSession.StartDebugSession(
powerShellContext,
hostUserInterface,
editorOperations);

return editorSession;
Expand Down
25 changes: 17 additions & 8 deletions src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,23 @@ protected async Task HandleConfigurationDoneRequest(

await requestContext.SendResult(null);

if (this.isInteractiveDebugSession &&
this.editorSession.DebugService.IsDebuggerStopped)
if (this.isInteractiveDebugSession)
{
// If this is an interactive session and there's a pending breakpoint,
// send that information along to the debugger client
this.DebugService_DebuggerStopped(
this,
this.editorSession.DebugService.CurrentDebuggerStoppedEventArgs);
if (this.ownsEditorSession)
{
// If this is a debug-only session, we need to start
// the command loop manually
this.editorSession.HostInput.StartCommandLoop();
}

if (this.editorSession.DebugService.IsDebuggerStopped)
{
// If this is an interactive session and there's a pending breakpoint,
// send that information along to the debugger client
this.DebugService_DebuggerStopped(
this,
this.editorSession.DebugService.CurrentDebuggerStoppedEventArgs);
}
}
}

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

// If the number of requested levels == 0 (or null), that means get all stack frames
// If the number of requested levels == 0 (or null), that means get all stack frames
// after the specified startFrame index. Otherwise get all the stack frames.
int requestedFrameCount = (stackTraceParams.Levels ?? 0);
if (requestedFrameCount > 0)
Expand Down
3 changes: 3 additions & 0 deletions src/PowerShellEditorServices/Session/EditorSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,17 @@ public void StartSession(
/// for the ConsoleService.
/// </summary>
/// <param name="powerShellContext"></param>
/// <param name="hostInput"></param>
/// <param name="editorOperations">
/// An IEditorOperations implementation used to interact with the editor.
/// </param>
public void StartDebugSession(
PowerShellContext powerShellContext,
IHostInput hostInput,
IEditorOperations editorOperations)
{
this.PowerShellContext = powerShellContext;
this.HostInput = hostInput;

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

0 comments on commit 19a13d9

Please sign in to comment.