@@ -46,6 +46,7 @@ public DebugAdapter(EditorSession editorSession, ChannelBase serverChannel)
4646 this . editorSession = editorSession ;
4747 this . editorSession . PowerShellContext . RunspaceChanged += this . powerShellContext_RunspaceChanged ;
4848 this . editorSession . DebugService . DebuggerStopped += this . DebugService_DebuggerStopped ;
49+ this . editorSession . PowerShellContext . DebuggerResumed += this . powerShellContext_DebuggerResumed ;
4950 }
5051
5152 public DebugAdapter (
@@ -60,6 +61,7 @@ public DebugAdapter(
6061 this . editorSession . StartDebugSession ( hostDetails , profilePaths , editorOperations ) ;
6162 this . editorSession . PowerShellContext . RunspaceChanged += this . powerShellContext_RunspaceChanged ;
6263 this . editorSession . DebugService . DebuggerStopped += this . DebugService_DebuggerStopped ;
64+ this . editorSession . PowerShellContext . DebuggerResumed += this . powerShellContext_DebuggerResumed ;
6365
6466 // The assumption in this overload is that the debugger
6567 // is running in UI-hosted mode, no terminal interface
@@ -295,6 +297,11 @@ await this.editorSession.PowerShellContext.ExecuteScriptString(
295297 "" , false , true ) ;
296298 }
297299
300+ if ( this . editorSession . ConsoleService . EnableConsoleRepl )
301+ {
302+ await this . WriteUseIntegratedConsoleMessage ( ) ;
303+ }
304+
298305 // Send the InitializedEvent so that the debugger will continue
299306 // sending configuration requests
300307 await this . SendEvent (
@@ -743,23 +750,30 @@ protected async Task HandleEvaluateRequest(
743750
744751 if ( isFromRepl )
745752 {
746- // Check for special commands
747- if ( string . Equals ( "!ctrlc" , evaluateParams . Expression , StringComparison . CurrentCultureIgnoreCase ) )
753+ if ( ! this . editorSession . ConsoleService . EnableConsoleRepl )
748754 {
749- editorSession . PowerShellContext . AbortExecution ( ) ;
750- }
751- else if ( string . Equals ( "!break" , evaluateParams . Expression , StringComparison . CurrentCultureIgnoreCase ) )
752- {
753- editorSession . DebugService . Break ( ) ;
755+ // Check for special commands
756+ if ( string . Equals ( "!ctrlc" , evaluateParams . Expression , StringComparison . CurrentCultureIgnoreCase ) )
757+ {
758+ editorSession . PowerShellContext . AbortExecution ( ) ;
759+ }
760+ else if ( string . Equals ( "!break" , evaluateParams . Expression , StringComparison . CurrentCultureIgnoreCase ) )
761+ {
762+ editorSession . DebugService . Break ( ) ;
763+ }
764+ else
765+ {
766+ // Send the input through the console service
767+ var notAwaited =
768+ this . editorSession
769+ . PowerShellContext
770+ . ExecuteScriptString ( evaluateParams . Expression , false , true )
771+ . ConfigureAwait ( false ) ;
772+ }
754773 }
755774 else
756775 {
757- // Send the input through the console service
758- var notAwaited =
759- this . editorSession
760- . PowerShellContext
761- . ExecuteScriptString ( evaluateParams . Expression , false , true )
762- . ConfigureAwait ( false ) ;
776+ await this . WriteUseIntegratedConsoleMessage ( ) ;
763777 }
764778 }
765779 else
@@ -770,10 +784,11 @@ protected async Task HandleEvaluateRequest(
770784 // has been resumed, return an empty result in this case.
771785 if ( editorSession . PowerShellContext . IsDebuggerStopped )
772786 {
773- await editorSession . DebugService . EvaluateExpression (
774- evaluateParams . Expression ,
775- evaluateParams . FrameId ,
776- isFromRepl ) ;
787+ result =
788+ await editorSession . DebugService . EvaluateExpression (
789+ evaluateParams . Expression ,
790+ evaluateParams . FrameId ,
791+ isFromRepl ) ;
777792 }
778793
779794 if ( result != null )
@@ -793,6 +808,17 @@ await requestContext.SendResult(
793808 } ) ;
794809 }
795810
811+ private async Task WriteUseIntegratedConsoleMessage ( )
812+ {
813+ await this . SendEvent (
814+ OutputEvent . Type ,
815+ new OutputEventBody
816+ {
817+ Output = "\n The Debug Console is no longer used for PowerShell debugging. Please use the 'PowerShell Integrated Console' to execute commands in the debugger. Run the 'PowerShell: Show Integrated Console' command to open it." ,
818+ Category = "stderr"
819+ } ) ;
820+ }
821+
796822 #endregion
797823
798824 #region Event Handlers
@@ -867,6 +893,17 @@ await this.SendEvent<ContinuedEvent>(
867893 }
868894 }
869895
896+ private async void powerShellContext_DebuggerResumed ( object sender , DebuggerResumeAction e )
897+ {
898+ await this . SendEvent (
899+ ContinuedEvent . Type ,
900+ new ContinuedEvent
901+ {
902+ AllThreadsContinued = true ,
903+ ThreadId = 1
904+ } ) ;
905+ }
906+
870907 #endregion
871908 }
872909}
0 commit comments