mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Reload the configured project only once even though there are multiple files open from that project
This commit is contained in:
parent
2a63827891
commit
96ffd53c2d
@ -871,24 +871,6 @@ namespace ts.server {
|
||||
return configFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function tries to search for a tsconfig.json for the given file. If we found it,
|
||||
* we first detect if there is already a configured project created for it: if so, we re-read
|
||||
* the tsconfig file content and update the project; otherwise we create a new one.
|
||||
*/
|
||||
private openOrUpdateConfiguredProjectForFile(fileName: NormalizedPath) {
|
||||
const configFileName = this.getConfigFileNameForFile(fileName);
|
||||
if (configFileName) {
|
||||
const project = this.findConfiguredProjectByProjectName(configFileName);
|
||||
if (!project) {
|
||||
this.openConfigFile(configFileName, fileName);
|
||||
}
|
||||
else {
|
||||
this.reloadConfiguredProject(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is different from the method the compiler uses because
|
||||
// the compiler can assume it will always start searching in the
|
||||
// current directory (the directory in which tsc was invoked).
|
||||
@ -1413,11 +1395,25 @@ namespace ts.server {
|
||||
*/
|
||||
reloadProjects() {
|
||||
this.logger.info("reload projects.");
|
||||
const mapUpdatedProjects = createMap<true>();
|
||||
// try to reload config file for all open files
|
||||
for (const info of this.openFiles) {
|
||||
// TODO: (sheetalkamat) batch these = multiple open files from the same project will
|
||||
// end up updating project that many times
|
||||
this.openOrUpdateConfiguredProjectForFile(info.fileName);
|
||||
// This tries to search for a tsconfig.json for the given file. If we found it,
|
||||
// we first detect if there is already a configured project created for it: if so,
|
||||
// we re- read the tsconfig file content and update the project only if we havent already done so
|
||||
// otherwise we create a new one.
|
||||
const configFileName = this.getConfigFileNameForFile(info.fileName);
|
||||
if (configFileName) {
|
||||
let project = this.findConfiguredProjectByProjectName(configFileName);
|
||||
if (!project) {
|
||||
project = this.openConfigFile(configFileName, info.fileName);
|
||||
mapUpdatedProjects.set(configFileName, true);
|
||||
}
|
||||
else if (!mapUpdatedProjects.has(configFileName)) {
|
||||
this.reloadConfiguredProject(project);
|
||||
mapUpdatedProjects.set(configFileName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.refreshInferredProjects();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user