Skip to content

Commit

Permalink
Do not generate config file diagnostics event when the file opened do…
Browse files Browse the repository at this point in the history
…esnot belong to the configured project
  • Loading branch information
sheetalkamat committed Oct 11, 2017
1 parent c5b4f5e commit bb4abbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
11 changes: 2 additions & 9 deletions src/harness/unittests/tsserverProjectSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3168,7 +3168,7 @@ namespace ts.projectSystem {
serverEventManager.checkEventCountOfType("configFileDiag", 3);
});

it("are generated when the config file doesnot include file opened but has errors", () => {
it("are not generated when the config file doesnot include file opened and config file has errors", () => {
const serverEventManager = new TestServerEventManager();
const file = {
path: "/a/b/app.ts",
Expand All @@ -3195,14 +3195,7 @@ namespace ts.projectSystem {
eventHandler: serverEventManager.handler
});
openFilesForSession([file2], session);
serverEventManager.checkEventCountOfType("configFileDiag", 1);
for (const event of serverEventManager.events) {
if (event.eventName === "configFileDiag") {
assert.equal(event.data.configFileName, configFile.path);
assert.equal(event.data.triggerFile, file2.path);
return;
}
}
serverEventManager.checkEventCountOfType("configFileDiag", 0);
});

it("are not generated when the config file doesnot include file opened and doesnt contain any errors", () => {
Expand Down
10 changes: 4 additions & 6 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1933,12 +1933,10 @@ namespace ts.server {
// At this point if file is part of any any configured or external project, then it would be present in the containing projects
// So if it still doesnt have any containing projects, it needs to be part of inferred project
if (info.isOrphan()) {
// Since the file isnt part of configured project,
// report config file and its error only if config file found had errors (and hence may be didnt include the file)
if (sendConfigFileDiagEvent && !project.getAllProjectErrors().length) {
configFileName = undefined;
sendConfigFileDiagEvent = false;
}
// Since the file isnt part of configured project, do not send config file event
configFileName = undefined;
sendConfigFileDiagEvent = false;

this.assignOrphanScriptInfoToInferredProject(info, projectRootPath);
}
this.addToListOfOpenFiles(info);
Expand Down

0 comments on commit bb4abbd

Please sign in to comment.