1- // Copyright (c) Microsoft Corporation.
1+ // Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
44using Microsoft . Extensions . Logging ;
@@ -70,33 +70,30 @@ public Task<ConfigurationDoneResponse> Handle(ConfigurationDoneArguments request
7070
7171 if ( _debugStateService . OwnsEditorSession )
7272 {
73- // If this is a debug-only session, we need to start
74- // the command loop manually
73+ // TODO: If this is a debug-only session, we need to start the command loop manually
74+ //
7575 //_powerShellContextService.ConsoleReader.StartCommandLoop();
7676 }
7777
7878 if ( ! string . IsNullOrEmpty ( _debugStateService . ScriptToLaunch ) )
7979 {
80- LaunchScriptAsync ( _debugStateService . ScriptToLaunch )
81- . HandleErrorsAsync ( _logger ) ;
80+ LaunchScriptAsync ( _debugStateService . ScriptToLaunch ) . HandleErrorsAsync ( _logger ) ;
8281 }
8382
84- if ( _debugStateService . IsInteractiveDebugSession )
83+ if ( _debugStateService . IsInteractiveDebugSession && _debugService . IsDebuggerStopped )
8584 {
86- if ( _debugService . IsDebuggerStopped )
85+ if ( _debugService . CurrentDebuggerStoppedEventArgs is not null )
8786 {
88- if ( _debugService . CurrentDebuggerStoppedEventArgs != null )
89- {
90- // If this is an interactive session and there's a pending breakpoint,
91- // send that information along to the debugger client
92- _debugEventHandlerService . TriggerDebuggerStopped ( _debugService . CurrentDebuggerStoppedEventArgs ) ;
93- }
94- else
95- {
96- // If this is an interactive session and there's a pending breakpoint that has not been propagated through
97- // the debug service, fire the debug service's OnDebuggerStop event.
98- _debugService . OnDebuggerStopAsync ( null , _debugContext . LastStopEventArgs ) ;
99- }
87+ // If this is an interactive session and there's a pending breakpoint, send that
88+ // information along to the debugger client.
89+ _debugEventHandlerService . TriggerDebuggerStopped ( _debugService . CurrentDebuggerStoppedEventArgs ) ;
90+ }
91+ else
92+ {
93+ // If this is an interactive session and there's a pending breakpoint that has
94+ // not been propagated through the debug service, fire the debug service's
95+ // OnDebuggerStop event.
96+ _debugService . OnDebuggerStopAsync ( null , _debugContext . LastStopEventArgs ) ;
10097 }
10198 }
10299
@@ -119,6 +116,8 @@ private async Task LaunchScriptAsync(string scriptToLaunch)
119116 ScriptBlockAst ast = Parser . ParseInput ( untitledScript . Contents , untitledScript . DocumentUri . ToString ( ) , out Token [ ] tokens , out ParseError [ ] errors ) ;
120117
121118 // This seems to be the simplest way to invoke a script block (which contains breakpoint information) via the PowerShell API.
119+ //
120+ // TODO: Fix this so the added script doesn't show up.
122121 var cmd = new PSCommand ( ) . AddScript ( ". $args[0]" ) . AddArgument ( ast . GetScriptBlock ( ) ) ;
123122 await _executionService
124123 . ExecutePSCommandAsync < object > ( cmd , CancellationToken . None , s_debuggerExecutionOptions )
0 commit comments