File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/PowerShellEditorServices/Services/PowerShell/Debugging Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 66using System . Threading ;
77using System . Threading . Tasks ;
88using Microsoft . Extensions . Logging ;
9+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Context ;
910using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
1011using Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility ;
1112
@@ -145,15 +146,27 @@ public void SetDebugResuming(DebuggerResumeAction debuggerResumeAction)
145146 // TODO: We need to assign cancellation tokens to each frame, because the current
146147 // logic results in a deadlock here when we try to cancel the scopes...which
147148 // includes ourself (hence running it in a separate thread).
148- Task . Run ( ( ) => _psesHost . UnwindCallStack ( ) ) ;
149+ _ = Task . Run ( ( ) => _psesHost . UnwindCallStack ( ) ) ;
149150 return ;
150151 }
151152
152153 // Otherwise we're continuing or stepping (i.e. resuming) so we need to cancel the
153154 // debugger REPL.
154- if ( _psesHost . CurrentFrame . IsRepl )
155+ PowerShellFrameType frameType = _psesHost . CurrentFrame . FrameType ;
156+ if ( frameType . HasFlag ( PowerShellFrameType . Repl ) )
155157 {
156158 _psesHost . CancelIdleParentTask ( ) ;
159+ return ;
160+ }
161+
162+ // If the user is running something via the REPL like `while ($true) { sleep 1 }`
163+ // and then tries to step, we want to stop that so that execution can resume.
164+ //
165+ // This also applies to anything we're running on debugger stop like watch variables.
166+ if ( frameType . HasFlag ( PowerShellFrameType . Debug | PowerShellFrameType . Nested ) )
167+ {
168+ _psesHost . ForceSetExit ( ) ;
169+ _psesHost . CancelIdleParentTask ( ) ;
157170 }
158171 }
159172
You can’t perform that action at this time.
0 commit comments