Skip to content

Commit ecf1ae2

Browse files
committed
Removed duplicate code from previous merge that fixed tests.
1 parent 1b17a96 commit ecf1ae2

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ bool ownsInitialRunspace
428428
else
429429
{
430430
logger.LogTrace("Creating initial PowerShell runspace");
431-
432431
initialRunspace = PowerShellContextService.CreateRunspace(psHost, hostStartupInfo.InitialSessionState);
433432
}
434433
logger.LogInformation("Opening Runspace");
@@ -512,41 +511,15 @@ bool ownsInitialRunspace
512511
.PSVariable
513512
.GetValue("Host")
514513
as PSHost;
515-
if(VersionUtils.IsWindows)
516-
{
517-
this.SetExecutionPolicy();
518-
}
519514
// Now that the runspace is ready, enqueue it for first use
520515
this.PromptNest = new PromptNest(
521516
this,
522517
this.powerShell,
523518
this.ConsoleReader,
524519
this.versionSpecificOperations);
525520
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-
}
548521

549-
522+
550523
if (powerShellVersion.Major >= 5 &&
551524
this.isPSReadLineEnabled &&
552525
PSReadLinePromptContext.TryGetPSReadLineProxy(logger, out PSReadLineProxy proxy))
@@ -582,7 +555,7 @@ bool ownsInitialRunspace
582555
this.ExecuteCommandAsync<PSObject>(
583556
command,
584557
sendOutputToHost: false,
585-
sendErrorToHost: true);
558+
sendErrorToHost: true).GetAwaiter().GetResult();
586559
#pragma warning restore CS4014
587560
}
588561
}

0 commit comments

Comments
 (0)