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.
22// Licensed under the MIT License.
33
44using System ;
@@ -502,9 +502,11 @@ private void PopPowerShell(RunspaceChangeAction runspaceChangeAction = RunspaceC
502502 PowerShellContextFrame frame = _psFrameStack . Pop ( ) ;
503503 try
504504 {
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.
506506 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 )
508510 {
509511 _runspaceStack . Pop ( ) ;
510512 RunspaceFrame currentRunspaceFrame = _runspaceStack . Peek ( ) ;
You can’t perform that action at this time.
0 commit comments