@@ -32,7 +32,7 @@ internal class PsesInternalHost : PSHost, IHostSupportsInteractiveSession, IRuns
32
32
private static string s_bundledModulePath = Path . GetFullPath ( Path . Combine (
33
33
Path . GetDirectoryName ( typeof ( PsesInternalHost ) . Assembly . Location ) , ".." , ".." , ".." ) ) ;
34
34
35
- private static string s_commandsModulePath => Path . GetFullPath ( Path . Combine (
35
+ private static string CommandsModulePath => Path . GetFullPath ( Path . Combine (
36
36
s_bundledModulePath , "PowerShellEditorServices" , "Commands" , "PowerShellEditorServices.Commands.psd1" ) ) ;
37
37
38
38
private readonly ILoggerFactory _loggerFactory ;
@@ -513,8 +513,7 @@ private void PopPowerShell(RunspaceChangeAction runspaceChangeAction = RunspaceC
513
513
{
514
514
// If we're changing runspace, make sure we move the handlers over. If we just
515
515
// 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 )
518
517
{
519
518
RunspaceFrame previousRunspaceFrame = _runspaceStack . Pop ( ) ;
520
519
RemoveRunspaceEventHandlers ( previousRunspaceFrame . Runspace ) ;
@@ -566,7 +565,6 @@ private void RunTopLevelExecutionLoop()
566
565
_stopped . SetResult ( true ) ;
567
566
}
568
567
569
-
570
568
private void RunDebugExecutionLoop ( )
571
569
{
572
570
try
@@ -584,16 +582,14 @@ private void RunExecutionLoop()
584
582
{
585
583
while ( ! ShouldExitExecutionLoop )
586
584
{
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 ) ;
590
587
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 ) ;
597
593
}
598
594
}
599
595
}
@@ -742,7 +738,7 @@ private static PowerShell CreatePowerShellForRunspace(Runspace runspace)
742
738
pwsh . SetCorrectExecutionPolicy ( _logger ) ;
743
739
}
744
740
745
- pwsh . ImportModule ( s_commandsModulePath ) ;
741
+ pwsh . ImportModule ( CommandsModulePath ) ;
746
742
747
743
if ( hostStartupInfo . AdditionalModules ? . Count > 0 )
748
744
{
@@ -884,7 +880,7 @@ private void OnRunspaceStateChanged(object sender, RunspaceStateEventArgs runspa
884
880
if ( ! ShouldExitExecutionLoop && ! _resettingRunspace && ! runspaceStateEventArgs . RunspaceStateInfo . IsUsable ( ) )
885
881
{
886
882
_resettingRunspace = true ;
887
- PopOrReinitializeRunspaceAsync ( ) . HandleErrorsAsync ( _logger ) ;
883
+ Task _ = PopOrReinitializeRunspaceAsync ( ) . HandleErrorsAsync ( _logger ) ;
888
884
}
889
885
}
890
886
@@ -898,7 +894,7 @@ private Task PopOrReinitializeRunspaceAsync()
898
894
return ExecuteDelegateAsync (
899
895
nameof ( PopOrReinitializeRunspaceAsync ) ,
900
896
new ExecutionOptions { InterruptCurrentForeground = true } ,
901
- ( cancellationToken ) =>
897
+ ( _ ) =>
902
898
{
903
899
while ( _psFrameStack . Count > 0
904
900
&& ! _psFrameStack . Peek ( ) . PowerShell . Runspace . RunspaceStateInfo . IsUsable ( ) )
0 commit comments