@@ -32,7 +32,7 @@ internal class PsesInternalHost : PSHost, IHostSupportsInteractiveSession, IRuns
3232 private static string s_bundledModulePath = Path . GetFullPath ( Path . Combine (
3333 Path . GetDirectoryName ( typeof ( PsesInternalHost ) . Assembly . Location ) , ".." , ".." , ".." ) ) ;
3434
35- private static string s_commandsModulePath => Path . GetFullPath ( Path . Combine (
35+ private static string CommandsModulePath => Path . GetFullPath ( Path . Combine (
3636 s_bundledModulePath , "PowerShellEditorServices" , "Commands" , "PowerShellEditorServices.Commands.psd1" ) ) ;
3737
3838 private readonly ILoggerFactory _loggerFactory ;
@@ -513,8 +513,7 @@ private void PopPowerShell(RunspaceChangeAction runspaceChangeAction = RunspaceC
513513 {
514514 // If we're changing runspace, make sure we move the handlers over. If we just
515515 // popped the last frame, then we're exiting and should pop the runspace too.
516- if ( _psFrameStack . Count == 0
517- || _runspaceStack . Peek ( ) . Runspace != _psFrameStack . Peek ( ) . PowerShell . Runspace )
516+ if ( _psFrameStack . Count == 0 || CurrentRunspace . Runspace != CurrentPowerShell . Runspace )
518517 {
519518 RunspaceFrame previousRunspaceFrame = _runspaceStack . Pop ( ) ;
520519 RemoveRunspaceEventHandlers ( previousRunspaceFrame . Runspace ) ;
@@ -566,7 +565,6 @@ private void RunTopLevelExecutionLoop()
566565 _stopped . SetResult ( true ) ;
567566 }
568567
569-
570568 private void RunDebugExecutionLoop ( )
571569 {
572570 try
@@ -584,16 +582,14 @@ private void RunExecutionLoop()
584582 {
585583 while ( ! ShouldExitExecutionLoop )
586584 {
587- using ( CancellationScope cancellationScope = _cancellationContext . EnterScope ( isIdleScope : false ) )
588- {
589- DoOneRepl ( cancellationScope . CancellationToken ) ;
585+ using CancellationScope cancellationScope = _cancellationContext . EnterScope ( isIdleScope : false ) ;
586+ DoOneRepl ( cancellationScope . CancellationToken ) ;
590587
591- while ( ! ShouldExitExecutionLoop
592- && ! cancellationScope . CancellationToken . IsCancellationRequested
593- && _taskQueue . TryTake ( out ISynchronousTask task ) )
594- {
595- task . ExecuteSynchronously ( cancellationScope . CancellationToken ) ;
596- }
588+ while ( ! ShouldExitExecutionLoop
589+ && ! cancellationScope . CancellationToken . IsCancellationRequested
590+ && _taskQueue . TryTake ( out ISynchronousTask task ) )
591+ {
592+ task . ExecuteSynchronously ( cancellationScope . CancellationToken ) ;
597593 }
598594 }
599595 }
@@ -742,7 +738,7 @@ private static PowerShell CreatePowerShellForRunspace(Runspace runspace)
742738 pwsh . SetCorrectExecutionPolicy ( _logger ) ;
743739 }
744740
745- pwsh . ImportModule ( s_commandsModulePath ) ;
741+ pwsh . ImportModule ( CommandsModulePath ) ;
746742
747743 if ( hostStartupInfo . AdditionalModules ? . Count > 0 )
748744 {
@@ -884,7 +880,7 @@ private void OnRunspaceStateChanged(object sender, RunspaceStateEventArgs runspa
884880 if ( ! ShouldExitExecutionLoop && ! _resettingRunspace && ! runspaceStateEventArgs . RunspaceStateInfo . IsUsable ( ) )
885881 {
886882 _resettingRunspace = true ;
887- PopOrReinitializeRunspaceAsync ( ) . HandleErrorsAsync ( _logger ) ;
883+ Task _ = PopOrReinitializeRunspaceAsync ( ) . HandleErrorsAsync ( _logger ) ;
888884 }
889885 }
890886
@@ -898,7 +894,7 @@ private Task PopOrReinitializeRunspaceAsync()
898894 return ExecuteDelegateAsync (
899895 nameof ( PopOrReinitializeRunspaceAsync ) ,
900896 new ExecutionOptions { InterruptCurrentForeground = true } ,
901- ( cancellationToken ) =>
897+ ( _ ) =>
902898 {
903899 while ( _psFrameStack . Count > 0
904900 && ! _psFrameStack . Peek ( ) . PowerShell . Runspace . RunspaceStateInfo . IsUsable ( ) )
0 commit comments