@@ -321,7 +321,7 @@ bool ownsInitialRunspace
321321 logger . LogTrace ( $ "Using new bundled module path: { hostStartupInfo . BundledModulePath } ") ;
322322 s_bundledModulePath = hostStartupInfo . BundledModulePath ;
323323 }
324-
324+
325325 modulesToImport . Add ( s_commandsModulePath ) ;
326326 if ( this . isPSReadLineEnabled )
327327 {
@@ -333,7 +333,7 @@ bool ownsInitialRunspace
333333 }
334334 bool preloadModules = ! hostStartupInfo . InitialSessionState . Providers . Any ( a => a . Name == "FileSystem" && a . Visibility == SessionStateEntryVisibility . Public ) ;
335335 EditorServicesPSHostUserInterface hostUserInterface =
336- hostStartupInfo . ConsoleReplEnabled
336+ hostStartupInfo . ConsoleReplEnabled && hostStartupInfo . PSHost is not null
337337 ? ( EditorServicesPSHostUserInterface ) new TerminalPSHostUserInterface ( this , hostStartupInfo . PSHost , logger )
338338 : new ProtocolPSHostUserInterface ( languageServer , this , logger ) ;
339339
@@ -453,7 +453,7 @@ bool ownsInitialRunspace
453453 this . logger . LogInformation ( $ "PowerShell Version: { this . LocalPowerShellVersion . Version } , Edition: { this . LocalPowerShellVersion . Edition } ") ;
454454
455455 Version powerShellVersion = this . LocalPowerShellVersion . Version ;
456- if ( powerShellVersion >= new Version ( 5 , 0 ) )
456+ if ( powerShellVersion >= new Version ( 5 , 0 ) )
457457 {
458458 this . versionSpecificOperations = new PowerShell5Operations ( ) ;
459459 }
@@ -472,7 +472,7 @@ bool ownsInitialRunspace
472472
473473 // Set the $profile variable in the runspace
474474 this . profilePaths = hostStartupInfo . ProfilePaths ;
475- if ( profilePaths != null )
475+ if ( profilePaths != null )
476476 {
477477 this . SetProfileVariableInCurrentRunspace ( profilePaths ) ;
478478 }
@@ -504,9 +504,9 @@ bool ownsInitialRunspace
504504 this . ConsoleReader ,
505505 this . versionSpecificOperations ) ;
506506 this . InvocationEventQueue = InvocationEventQueue . Create ( this , this . PromptNest ) ;
507-
508-
509- if ( powerShellVersion . Major >= 5 &&
507+
508+
509+ if ( powerShellVersion . Major >= 5 &&
510510 this . isPSReadLineEnabled &&
511511 PSReadLinePromptContext . TryGetPSReadLineProxy ( logger , out PSReadLineProxy proxy ) )
512512 {
@@ -520,7 +520,7 @@ bool ownsInitialRunspace
520520 {
521521 this . PromptContext = new LegacyReadLineContext ( this ) ;
522522 }
523-
523+
524524 if ( ! preloadModules )
525525 {
526526 // TODO: This can be moved to the point after the $psEditor object
0 commit comments