@@ -218,9 +218,15 @@ namespace ts.server {
218218 }
219219 }
220220
221+ /*@internal */
222+ export function convertUserPreferences ( preferences : protocol . UserPreferences ) : UserPreferences {
223+ const { lazyConfiguredProjectsFromExternalProject, ...userPreferences } = preferences ;
224+ return userPreferences ;
225+ }
226+
221227 export interface HostConfiguration {
222228 formatCodeOptions : FormatCodeSettings ;
223- preferences : UserPreferences ;
229+ preferences : protocol . UserPreferences ;
224230 hostInfo : string ;
225231 extraFileExtensions ?: FileExtensionInfo [ ] ;
226232 }
@@ -802,7 +808,7 @@ namespace ts.server {
802808 return info && info . getFormatCodeSettings ( ) || this . hostConfiguration . formatCodeOptions ;
803809 }
804810
805- getPreferences ( file : NormalizedPath ) : UserPreferences {
811+ getPreferences ( file : NormalizedPath ) : protocol . UserPreferences {
806812 const info = this . getScriptInfoForNormalizedPath ( file ) ;
807813 return info && info . getPreferences ( ) || this . hostConfiguration . preferences ;
808814 }
@@ -811,7 +817,7 @@ namespace ts.server {
811817 return this . hostConfiguration . formatCodeOptions ;
812818 }
813819
814- getHostPreferences ( ) : UserPreferences {
820+ getHostPreferences ( ) : protocol . UserPreferences {
815821 return this . hostConfiguration . preferences ;
816822 }
817823
@@ -1561,6 +1567,13 @@ namespace ts.server {
15611567 return project ;
15621568 }
15631569
1570+ /* @internal */
1571+ private createLoadAndUpdateConfiguredProject ( configFileName : NormalizedPath ) {
1572+ const project = this . createAndLoadConfiguredProject ( configFileName ) ;
1573+ project . updateGraph ( ) ;
1574+ return project ;
1575+ }
1576+
15641577 /**
15651578 * Read the config file of the project, and update the project root file names.
15661579 */
@@ -1979,7 +1992,19 @@ namespace ts.server {
19791992 this . logger . info ( "Format host information updated" ) ;
19801993 }
19811994 if ( args . preferences ) {
1995+ const { lazyConfiguredProjectsFromExternalProject } = this . hostConfiguration . preferences ;
19821996 this . hostConfiguration . preferences = { ...this . hostConfiguration . preferences , ...args . preferences } ;
1997+ if ( lazyConfiguredProjectsFromExternalProject && ! this . hostConfiguration . preferences . lazyConfiguredProjectsFromExternalProject ) {
1998+ // Load configured projects for external projects that are pending reload
1999+ this . configuredProjects . forEach ( project => {
2000+ if ( project . hasExternalProjectRef ( ) &&
2001+ project . pendingReload === ConfigFileProgramReloadLevel . Full &&
2002+ ! this . pendingProjectUpdates . has ( project . getProjectName ( ) ) ) {
2003+ this . loadConfiguredProject ( project ) ;
2004+ project . updateGraph ( ) ;
2005+ }
2006+ } ) ;
2007+ }
19832008 }
19842009 if ( args . extraFileExtensions ) {
19852010 this . hostConfiguration . extraFileExtensions = args . extraFileExtensions ;
@@ -2192,8 +2217,7 @@ namespace ts.server {
21922217 if ( configFileName ) {
21932218 project = this . findConfiguredProjectByProjectName ( configFileName ) ;
21942219 if ( ! project ) {
2195- project = this . createAndLoadConfiguredProject ( configFileName ) ;
2196- project . updateGraph ( ) ;
2220+ project = this . createLoadAndUpdateConfiguredProject ( configFileName ) ;
21972221 // Send the event only if the project got created as part of this open request and info is part of the project
21982222 if ( info . isOrphan ( ) ) {
21992223 // Since the file isnt part of configured project, do not send config file info
@@ -2633,7 +2657,9 @@ namespace ts.server {
26332657 let project = this . findConfiguredProjectByProjectName ( tsconfigFile ) ;
26342658 if ( ! project ) {
26352659 // errors are stored in the project, do not need to update the graph
2636- project = this . createConfiguredProjectWithDelayLoad ( tsconfigFile ) ;
2660+ project = this . getHostPreferences ( ) . lazyConfiguredProjectsFromExternalProject ?
2661+ this . createConfiguredProjectWithDelayLoad ( tsconfigFile ) :
2662+ this . createLoadAndUpdateConfiguredProject ( tsconfigFile ) ;
26372663 }
26382664 if ( project && ! contains ( exisingConfigFiles , tsconfigFile ) ) {
26392665 // keep project alive even if no documents are opened - its lifetime is bound to the lifetime of containing external project
0 commit comments