@@ -428,7 +428,6 @@ bool ownsInitialRunspace
428
428
else
429
429
{
430
430
logger . LogTrace ( "Creating initial PowerShell runspace" ) ;
431
-
432
431
initialRunspace = PowerShellContextService . CreateRunspace ( psHost , hostStartupInfo . InitialSessionState ) ;
433
432
}
434
433
logger . LogInformation ( "Opening Runspace" ) ;
@@ -512,41 +511,15 @@ bool ownsInitialRunspace
512
511
. PSVariable
513
512
. GetValue ( "Host" )
514
513
as PSHost ;
515
- if ( VersionUtils . IsWindows )
516
- {
517
- this . SetExecutionPolicy ( ) ;
518
- }
519
514
// Now that the runspace is ready, enqueue it for first use
520
515
this . PromptNest = new PromptNest (
521
516
this ,
522
517
this . powerShell ,
523
518
this . ConsoleReader ,
524
519
this . versionSpecificOperations ) ;
525
520
this . InvocationEventQueue = InvocationEventQueue . Create ( this , this . PromptNest ) ;
526
- this . ImportCommandsModuleAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
527
- if ( isPSReadLineEnabled )
528
- {
529
- this . ImportPSReadLine2ModuleAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
530
- }
531
- // TODO: This can be moved to the point after the $psEditor object
532
- // gets initialized when that is done earlier than LanguageServer.Initialize
533
- foreach ( string module in hostStartupInfo . AdditionalModules )
534
- {
535
- var command =
536
- new PSCommand ( )
537
- . AddCommand ( "Microsoft.PowerShell.Core\\ Import-Module" )
538
- . AddParameter ( "Name" , module ) ;
539
-
540
- #pragma warning disable CS4014
541
- // This call queues the loading on the pipeline thread, so no need to await
542
- this . ExecuteCommandAsync < PSObject > (
543
- command ,
544
- sendOutputToHost : false ,
545
- sendErrorToHost : true ) ;
546
- #pragma warning restore CS4014
547
- }
548
521
549
-
522
+
550
523
if ( powerShellVersion . Major >= 5 &&
551
524
this . isPSReadLineEnabled &&
552
525
PSReadLinePromptContext . TryGetPSReadLineProxy ( logger , out PSReadLineProxy proxy ) )
@@ -582,7 +555,7 @@ bool ownsInitialRunspace
582
555
this . ExecuteCommandAsync < PSObject > (
583
556
command ,
584
557
sendOutputToHost : false ,
585
- sendErrorToHost : true ) ;
558
+ sendErrorToHost : true ) . GetAwaiter ( ) . GetResult ( ) ;
586
559
#pragma warning restore CS4014
587
560
}
588
561
}
0 commit comments