@@ -1001,7 +1001,8 @@ enum ProjectAncestorLoadKind {
1001
1001
FindCreateDelayLoad ,
1002
1002
}
1003
1003
1004
- enum ConfiguredProjectKind {
1004
+ /** @internal */
1005
+ export enum ConfiguredProjectKind {
1005
1006
Find ,
1006
1007
Create ,
1007
1008
Reload ,
@@ -1784,7 +1785,7 @@ export class ProjectService {
1784
1785
}
1785
1786
1786
1787
/** @internal */
1787
- private onConfigFileChanged ( canonicalConfigFilePath : NormalizedPath , eventKind : FileWatcherEventKind ) {
1788
+ private onConfigFileChanged ( configFileName : NormalizedPath , canonicalConfigFilePath : NormalizedPath , eventKind : FileWatcherEventKind ) {
1788
1789
const configFileExistenceInfo = this . configFileExistenceInfoCache . get ( canonicalConfigFilePath ) ! ;
1789
1790
if ( eventKind === FileWatcherEventKind . Deleted ) {
1790
1791
// Update the cached status
@@ -1797,15 +1798,14 @@ export class ProjectService {
1797
1798
this . getConfiguredProjectByCanonicalConfigFilePath ( canonicalConfigFilePath ) :
1798
1799
undefined ;
1799
1800
if ( project ) this . removeProject ( project ) ;
1800
- // TODO:: sheetal configFileForOpenFiles:: update needed when deleting ancestor project
1801
1801
}
1802
1802
else {
1803
1803
// Update the cached status
1804
1804
configFileExistenceInfo . exists = true ;
1805
1805
}
1806
1806
1807
1807
// Update projects watching config
1808
- this . delayUpdateProjectsFromParsedConfigOnConfigFileChange ( canonicalConfigFilePath , " Change in config file detected" ) ;
1808
+ this . delayUpdateProjectsFromParsedConfigOnConfigFileChange ( canonicalConfigFilePath , ` Change in config file ${ configFileName } detected` ) ;
1809
1809
1810
1810
// Reload the configured projects for the open files in the map as they are affected by this config file
1811
1811
// If the configured project was deleted, we want to reload projects for all the open files including files
@@ -1814,11 +1814,11 @@ export class ProjectService {
1814
1814
// we would need to schedule the project reload for only the root of inferred projects
1815
1815
// Get open files to reload projects for
1816
1816
const updatedProjects = new Set < ConfiguredProject > ( ) ;
1817
+ // Add the already scheduled project as updated
1818
+ if ( configFileExistenceInfo . config ?. projects . has ( canonicalConfigFilePath ) ) {
1819
+ updatedProjects . add ( this . findConfiguredProjectByProjectName ( configFileName ) ! ) ;
1820
+ }
1817
1821
configFileExistenceInfo . openFilesImpactedByConfigFile ?. forEach ( ( isRootOfInferredProject , path ) => {
1818
- // Filter out the files that need to be ignored
1819
- // If file is added or modified, reload the project only for open files that are not root of inferred project
1820
- if ( eventKind !== FileWatcherEventKind . Deleted && ! isRootOfInferredProject ) return ;
1821
-
1822
1822
// Invalidate default config file name for open file
1823
1823
this . configFileForOpenFiles . delete ( path ) ;
1824
1824
@@ -1833,11 +1833,10 @@ export class ProjectService {
1833
1833
const project = this . findConfiguredProjectByProjectName ( configFileName ) || this . createConfiguredProject ( configFileName ) ;
1834
1834
if ( tryAddToSet ( updatedProjects , project ) ) {
1835
1835
project . pendingUpdateLevel = ProgramUpdateLevel . Full ;
1836
- project . pendingUpdateReason = " Change in config file detected" ;
1836
+ project . pendingUpdateReason = ` Change in config file ${ configFileName } detected` ;
1837
1837
this . delayUpdateProjectGraph ( project ) ;
1838
1838
}
1839
- // TODO:: After this update we need to ensure that we try and create Project for the open script info (through refs etc)
1840
- // TODO:: sheetal: ensureProjectForOpenFile needs to handle that?
1839
+ ( project . pendingOpenFileProjectUpdates ??= new Set ( ) ) . add ( path ) ;
1841
1840
}
1842
1841
} ) ;
1843
1842
@@ -2087,7 +2086,7 @@ export class ProjectService {
2087
2086
if ( ! configFileExistenceInfo . watcher || configFileExistenceInfo . watcher === noopConfigFileWatcher ) {
2088
2087
configFileExistenceInfo . watcher = this . watchFactory . watchFile (
2089
2088
configFileName ,
2090
- ( _fileName , eventKind ) => this . onConfigFileChanged ( canonicalConfigFilePath , eventKind ) ,
2089
+ ( _fileName , eventKind ) => this . onConfigFileChanged ( configFileName , canonicalConfigFilePath , eventKind ) ,
2091
2090
PollingInterval . High ,
2092
2091
this . getWatchOptionsFromProjectWatchOptions ( configFileExistenceInfo ?. config ?. parsedCommandLine ?. watchOptions ) ,
2093
2092
WatchType . ConfigFile ,
@@ -2217,7 +2216,7 @@ export class ProjectService {
2217
2216
configFileExistenceInfo . watcher ||= canWatchDirectoryOrFile ( getPathComponents ( getDirectoryPath ( canonicalConfigFilePath ) as Path ) ) ?
2218
2217
this . watchFactory . watchFile (
2219
2218
configFileName ,
2220
- ( _filename , eventKind ) => this . onConfigFileChanged ( canonicalConfigFilePath , eventKind ) ,
2219
+ ( _filename , eventKind ) => this . onConfigFileChanged ( configFileName , canonicalConfigFilePath , eventKind ) ,
2221
2220
PollingInterval . High ,
2222
2221
this . hostConfiguration . watchOptions ,
2223
2222
WatchType . ConfigFileForInferredRoot ,
@@ -3828,9 +3827,11 @@ export class ProjectService {
3828
3827
return info ;
3829
3828
}
3830
3829
3831
- private tryFindDefaultConfiguredProjectForOpenScriptInfo ( info : ScriptInfo , kind : ConfiguredProjectKind . Find | ConfiguredProjectKind . Create ) : DefaultConfiguredProjectResult | undefined ;
3832
- private tryFindDefaultConfiguredProjectForOpenScriptInfo ( info : ScriptInfo , kind : ConfiguredProjectKind . Reload , reloadedProjects : Set < ConfiguredProject > ) : DefaultConfiguredProjectResult | undefined ;
3833
- private tryFindDefaultConfiguredProjectForOpenScriptInfo ( info : ScriptInfo , kind : ConfiguredProjectKind , reloadedProjects ?: Set < ConfiguredProject > ) : string | DefaultConfiguredProjectResult | undefined {
3830
+ /** @internal */
3831
+ tryFindDefaultConfiguredProjectForOpenScriptInfo ( info : ScriptInfo , kind : ConfiguredProjectKind . Find | ConfiguredProjectKind . Create ) : DefaultConfiguredProjectResult | undefined ;
3832
+ /** @internal */
3833
+ tryFindDefaultConfiguredProjectForOpenScriptInfo ( info : ScriptInfo , kind : ConfiguredProjectKind . Reload , reloadedProjects : Set < ConfiguredProject > ) : DefaultConfiguredProjectResult | undefined ;
3834
+ tryFindDefaultConfiguredProjectForOpenScriptInfo ( info : ScriptInfo , kind : ConfiguredProjectKind , reloadedProjects ?: Set < ConfiguredProject > ) : string | DefaultConfiguredProjectResult | undefined {
3834
3835
const configFileName = this . getConfigFileNameForFile ( info , kind === ConfiguredProjectKind . Find ) ;
3835
3836
if ( ! configFileName ) return ;
3836
3837
let project = this . findConfiguredProjectByProjectName ( configFileName ) ;
0 commit comments