File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/PowerShellEditorServices/Services/PowerShell/Host Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1
- // Copyright (c) Microsoft Corporation.
1
+ // Copyright (c) Microsoft Corporation.
2
2
// Licensed under the MIT License.
3
3
4
4
using System ;
@@ -502,9 +502,11 @@ private void PopPowerShell(RunspaceChangeAction runspaceChangeAction = RunspaceC
502
502
PowerShellContextFrame frame = _psFrameStack . Pop ( ) ;
503
503
try
504
504
{
505
- // If we're changing runspace, make sure we move the handlers over
505
+ // If we're changing runspace, make sure we move the handlers over.
506
506
RunspaceFrame previousRunspaceFrame = _runspaceStack . Peek ( ) ;
507
- if ( previousRunspaceFrame . Runspace != CurrentPowerShell . Runspace )
507
+ // Because the frame has been popped, we cannot rely on 'CurrentPowerShell.Runspace'
508
+ // as it may be empty.
509
+ if ( previousRunspaceFrame . Runspace != frame . PowerShell . Runspace )
508
510
{
509
511
_runspaceStack . Pop ( ) ;
510
512
RunspaceFrame currentRunspaceFrame = _runspaceStack . Peek ( ) ;
You can’t perform that action at this time.
0 commit comments