File tree 1 file changed +15
-2
lines changed
src/PowerShellEditorServices/Services/PowerShell/Debugging
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 6
6
using System . Threading ;
7
7
using System . Threading . Tasks ;
8
8
using Microsoft . Extensions . Logging ;
9
+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Context ;
9
10
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
10
11
using Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility ;
11
12
@@ -145,15 +146,27 @@ public void SetDebugResuming(DebuggerResumeAction debuggerResumeAction)
145
146
// TODO: We need to assign cancellation tokens to each frame, because the current
146
147
// logic results in a deadlock here when we try to cancel the scopes...which
147
148
// includes ourself (hence running it in a separate thread).
148
- Task . Run ( ( ) => _psesHost . UnwindCallStack ( ) ) ;
149
+ _ = Task . Run ( ( ) => _psesHost . UnwindCallStack ( ) ) ;
149
150
return ;
150
151
}
151
152
152
153
// Otherwise we're continuing or stepping (i.e. resuming) so we need to cancel the
153
154
// debugger REPL.
154
- if ( _psesHost . CurrentFrame . IsRepl )
155
+ PowerShellFrameType frameType = _psesHost . CurrentFrame . FrameType ;
156
+ if ( frameType . HasFlag ( PowerShellFrameType . Repl ) )
155
157
{
156
158
_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 ( ) ;
157
170
}
158
171
}
159
172
You can’t perform that action at this time.
0 commit comments