@@ -321,7 +321,7 @@ bool ownsInitialRunspace
321
321
logger . LogTrace ( $ "Using new bundled module path: { hostStartupInfo . BundledModulePath } ") ;
322
322
s_bundledModulePath = hostStartupInfo . BundledModulePath ;
323
323
}
324
-
324
+
325
325
modulesToImport . Add ( s_commandsModulePath ) ;
326
326
if ( this . isPSReadLineEnabled )
327
327
{
@@ -333,7 +333,7 @@ bool ownsInitialRunspace
333
333
}
334
334
bool preloadModules = ! hostStartupInfo . InitialSessionState . Providers . Any ( a => a . Name == "FileSystem" && a . Visibility == SessionStateEntryVisibility . Public ) ;
335
335
EditorServicesPSHostUserInterface hostUserInterface =
336
- hostStartupInfo . ConsoleReplEnabled
336
+ hostStartupInfo . ConsoleReplEnabled && hostStartupInfo . PSHost is not null
337
337
? ( EditorServicesPSHostUserInterface ) new TerminalPSHostUserInterface ( this , hostStartupInfo . PSHost , logger )
338
338
: new ProtocolPSHostUserInterface ( languageServer , this , logger ) ;
339
339
@@ -453,7 +453,7 @@ bool ownsInitialRunspace
453
453
this . logger . LogInformation ( $ "PowerShell Version: { this . LocalPowerShellVersion . Version } , Edition: { this . LocalPowerShellVersion . Edition } ") ;
454
454
455
455
Version powerShellVersion = this . LocalPowerShellVersion . Version ;
456
- if ( powerShellVersion >= new Version ( 5 , 0 ) )
456
+ if ( powerShellVersion >= new Version ( 5 , 0 ) )
457
457
{
458
458
this . versionSpecificOperations = new PowerShell5Operations ( ) ;
459
459
}
@@ -472,7 +472,7 @@ bool ownsInitialRunspace
472
472
473
473
// Set the $profile variable in the runspace
474
474
this . profilePaths = hostStartupInfo . ProfilePaths ;
475
- if ( profilePaths != null )
475
+ if ( profilePaths != null )
476
476
{
477
477
this . SetProfileVariableInCurrentRunspace ( profilePaths ) ;
478
478
}
@@ -504,9 +504,9 @@ bool ownsInitialRunspace
504
504
this . ConsoleReader ,
505
505
this . versionSpecificOperations ) ;
506
506
this . InvocationEventQueue = InvocationEventQueue . Create ( this , this . PromptNest ) ;
507
-
508
-
509
- if ( powerShellVersion . Major >= 5 &&
507
+
508
+
509
+ if ( powerShellVersion . Major >= 5 &&
510
510
this . isPSReadLineEnabled &&
511
511
PSReadLinePromptContext . TryGetPSReadLineProxy ( logger , out PSReadLineProxy proxy ) )
512
512
{
@@ -520,7 +520,7 @@ bool ownsInitialRunspace
520
520
{
521
521
this . PromptContext = new LegacyReadLineContext ( this ) ;
522
522
}
523
-
523
+
524
524
if ( ! preloadModules )
525
525
{
526
526
// TODO: This can be moved to the point after the $psEditor object
0 commit comments