Skip to content

Commit ff83b36

Browse files
committed
Fixed method names and other issues from merge.
1 parent 6b03c35 commit ff83b36

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public static Runspace CreateTestRunspace(
262262
/// <param name="psHost">The PSHost that will be used for this Runspace.</param>
263263
/// <param name="languageMode">The language mode inherited from the orginal PowerShell process. This will be used when creating runspaces so that we honor the same language mode.</param>
264264
/// <returns></returns>
265-
public static Runspace CreateTestRunspace(PSHost psHost, InitialSessionState initialSessionState, List<string> additionalModules = null)
265+
public static Runspace CreateRunspace(PSHost psHost, InitialSessionState initialSessionState, List<string> additionalModules = null)
266266
{
267267
Runspace runspace = RunspaceFactory.CreateRunspace(psHost, initialSessionState);
268268

@@ -409,13 +409,12 @@ bool ownsInitialRunspace
409409
hostStartupInfo.InitialSessionState.AddCommandAndAliasToInitialSessionState<OutDefaultCommand>(@"Microsoft.PowerShell.Core\Out-Default");
410410
//hostStartupInfo.InitialSessionState.AddCommandAndAliasToInitialSessionState<Microsoft.PowerShell.Commands.WriteHostCommand>(@"Microsoft.PowerShell.Core\Write-Host");
411411

412-
413-
initialRunspace = PowerShellContextService.CreateRunspace(hostStartupInfo.PSHost, hostStartupInfo.InitialSessionState);
412+
initialRunspace = CreateRunspace(hostStartupInfo.PSHost, hostStartupInfo.InitialSessionState);
414413
}
415414
else
416415
{
417416
logger.LogTrace("Creating initial PowerShell runspace");
418-
initialRunspace = PowerShellContextService.CreateRunspace(psHost, hostStartupInfo.InitialSessionState);
417+
initialRunspace = CreateRunspace(psHost, hostStartupInfo.InitialSessionState);
419418
}
420419
logger.LogInformation("Opening Runspace");
421420
initialRunspace.Open();
@@ -521,25 +520,7 @@ bool ownsInitialRunspace
521520
{
522521
this.PromptContext = new LegacyReadLineContext(this);
523522
}
524-
}
525-
526-
/// <summary>
527-
/// Imports the PowerShellEditorServices.Commands module into
528-
/// the runspace. This method will be moved somewhere else soon.
529-
/// </summary>
530-
/// <returns></returns>
531-
public Task ImportCommandsModuleAsync()
532-
{
533-
this.logger.LogTrace($"Importing PowershellEditorServices commands from {s_commandsModulePath}");
534-
535-
PSCommand importCommand = new PSCommand()
536-
.AddCommand("Import-Module")
537-
.AddArgument(s_commandsModulePath);
538-
539-
if (VersionUtils.IsWindows && initialRunspace.InitialSessionState.LanguageMode == PSLanguageMode.FullLanguage)
540-
{
541-
this.SetExecutionPolicy();
542-
}
523+
543524
if(!preloadModules)
544525
{
545526
// TODO: This can be moved to the point after the $psEditor object

test/PowerShellEditorServices.Test/PowerShellContextFactory.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ internal static class PowerShellContextFactory
4141
public static System.Management.Automation.Runspaces.Runspace InitialRunspace;
4242
public static PowerShellContextService Create(ILogger logger, bool isPSReadLineEnabled = false)
4343
{
44-
PowerShellContextService powerShellContext = new PowerShellContextService(logger, null, isPSReadLineEnabled: false);
4544
var initialSessionState = InitialSessionState.CreateDefault();
4645
// We set the process scope's execution policy (which is really the runspace's scope) to
4746
// Bypass so we can import our bundled modules. This is equivalent in scope to the CLI
@@ -65,7 +64,7 @@ public static PowerShellContextService Create(ILogger logger, bool isPSReadLineE
6564
consoleReplEnabled: isPSReadLineEnabled,
6665
usesLegacyReadLine: false,
6766
bundledModulePath: BundledModulePath);
68-
67+
PowerShellContextService powerShellContext = new PowerShellContextService(logger, null, testHostDetails);
6968
InitialRunspace = PowerShellContextService.CreateTestRunspace(
7069
testHostDetails,
7170
powerShellContext,

0 commit comments

Comments
 (0)