diff --git a/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs b/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs index ffbb065de..af9d9b342 100644 --- a/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs +++ b/src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs @@ -26,6 +26,7 @@ public class DebugAdapter : DebugAdapterBase private OutputDebouncer outputDebouncer; private bool noDebug; + private string arguments; private bool isRemoteAttach; private bool isAttachSession; private bool waitingForAttach; @@ -33,7 +34,7 @@ public class DebugAdapter : DebugAdapterBase private bool enableConsoleRepl; private bool ownsEditorSession; private bool executionCompleted; - private string arguments; + private bool isInteractiveDebugSession; private RequestContext disconnectRequestContext = null; public DebugAdapter(HostDetails hostDetails, ProfilePaths profilePaths) @@ -303,13 +304,9 @@ protected async Task HandleLaunchRequest( await requestContext.SendResult(null); - // If no script is being launched, execute an empty script to - // cause the prompt string to be evaluated and displayed - if (string.IsNullOrEmpty(this.scriptToLaunch)) - { - await this.editorSession.PowerShellContext.ExecuteScriptString( - "", false, true); - } + // If no script is being launched, mark this as an interactive + // debugging session + this.isInteractiveDebugSession = string.IsNullOrEmpty(this.scriptToLaunch); if (this.editorSession.ConsoleService.EnableConsoleRepl) { @@ -447,6 +444,11 @@ protected async Task HandleDisconnectRequest( { this.disconnectRequestContext = requestContext; this.editorSession.PowerShellContext.AbortExecution(); + + if (this.isInteractiveDebugSession) + { + await this.OnExecutionCompleted(null); + } } else {