@@ -218,9 +218,15 @@ namespace ts.server {
218
218
}
219
219
}
220
220
221
+ /*@internal */
222
+ export function convertUserPreferences ( preferences : protocol . UserPreferences ) : UserPreferences {
223
+ const { lazyConfiguredProjectsFromExternalProject, ...userPreferences } = preferences ;
224
+ return userPreferences ;
225
+ }
226
+
221
227
export interface HostConfiguration {
222
228
formatCodeOptions : FormatCodeSettings ;
223
- preferences : UserPreferences ;
229
+ preferences : protocol . UserPreferences ;
224
230
hostInfo : string ;
225
231
extraFileExtensions ?: FileExtensionInfo [ ] ;
226
232
}
@@ -802,7 +808,7 @@ namespace ts.server {
802
808
return info && info . getFormatCodeSettings ( ) || this . hostConfiguration . formatCodeOptions ;
803
809
}
804
810
805
- getPreferences ( file : NormalizedPath ) : UserPreferences {
811
+ getPreferences ( file : NormalizedPath ) : protocol . UserPreferences {
806
812
const info = this . getScriptInfoForNormalizedPath ( file ) ;
807
813
return info && info . getPreferences ( ) || this . hostConfiguration . preferences ;
808
814
}
@@ -811,7 +817,7 @@ namespace ts.server {
811
817
return this . hostConfiguration . formatCodeOptions ;
812
818
}
813
819
814
- getHostPreferences ( ) : UserPreferences {
820
+ getHostPreferences ( ) : protocol . UserPreferences {
815
821
return this . hostConfiguration . preferences ;
816
822
}
817
823
@@ -1561,6 +1567,13 @@ namespace ts.server {
1561
1567
return project ;
1562
1568
}
1563
1569
1570
+ /* @internal */
1571
+ private createLoadAndUpdateConfiguredProject ( configFileName : NormalizedPath ) {
1572
+ const project = this . createAndLoadConfiguredProject ( configFileName ) ;
1573
+ project . updateGraph ( ) ;
1574
+ return project ;
1575
+ }
1576
+
1564
1577
/**
1565
1578
* Read the config file of the project, and update the project root file names.
1566
1579
*/
@@ -1979,7 +1992,19 @@ namespace ts.server {
1979
1992
this . logger . info ( "Format host information updated" ) ;
1980
1993
}
1981
1994
if ( args . preferences ) {
1995
+ const { lazyConfiguredProjectsFromExternalProject } = this . hostConfiguration . preferences ;
1982
1996
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
+ }
1983
2008
}
1984
2009
if ( args . extraFileExtensions ) {
1985
2010
this . hostConfiguration . extraFileExtensions = args . extraFileExtensions ;
@@ -2192,8 +2217,7 @@ namespace ts.server {
2192
2217
if ( configFileName ) {
2193
2218
project = this . findConfiguredProjectByProjectName ( configFileName ) ;
2194
2219
if ( ! project ) {
2195
- project = this . createAndLoadConfiguredProject ( configFileName ) ;
2196
- project . updateGraph ( ) ;
2220
+ project = this . createLoadAndUpdateConfiguredProject ( configFileName ) ;
2197
2221
// Send the event only if the project got created as part of this open request and info is part of the project
2198
2222
if ( info . isOrphan ( ) ) {
2199
2223
// Since the file isnt part of configured project, do not send config file info
@@ -2633,7 +2657,9 @@ namespace ts.server {
2633
2657
let project = this . findConfiguredProjectByProjectName ( tsconfigFile ) ;
2634
2658
if ( ! project ) {
2635
2659
// 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 ) ;
2637
2663
}
2638
2664
if ( project && ! contains ( exisingConfigFiles , tsconfigFile ) ) {
2639
2665
// keep project alive even if no documents are opened - its lifetime is bound to the lifetime of containing external project
0 commit comments