Skip to content

Commit c2d0d53

Browse files
committed
dispose the watched wild card directories only if present
1 parent 476157f commit c2d0d53

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,32 @@ namespace ts.projectSystem {
23322332
const navbar = projectService.externalProjects[0].getLanguageService(/*ensureSynchronized*/ false).getNavigationBarItems(f1.path);
23332333
assert.equal(navbar[0].spans[0].length, f1.content.length);
23342334
});
2335+
2336+
it("deleting config file opened from the external project works", () => {
2337+
const site = {
2338+
path: "/user/someuser/project/js/site.js",
2339+
content: ""
2340+
};
2341+
const configFile = {
2342+
path: "/user/someuser/project/tsconfig.json",
2343+
content: "{}"
2344+
};
2345+
const projectFileName = "/user/someuser/project/WebApplication6.csproj";
2346+
const host = createServerHost([libFile, site, configFile]);
2347+
const projectService = createProjectService(host);
2348+
projectService.openExternalProjects([{
2349+
projectFileName,
2350+
rootFiles: [toExternalFile(configFile.path), toExternalFile(site.path)],
2351+
options: { "allowJs": false, "allowNonTsExtensions": false, "allowSyntheticDefaultImports": false, "allowUnreachableCode": false, "allowUnusedLabels": false, "alwaysStrict": false, "compileOnSave": true, "declaration": false, "emitBOM": false, "emitDecoratorMetadata": false, "experimentalAsyncFunctions": false, "experimentalDecorators": false, "forceConsistentCasingInFileNames": false, "importHelpers": false, "inlineSourceMap": false, "inlineSources": false, "isolatedModules": false, "jsx": 0, "noEmit": false, "noEmitHelpers": false, "noEmitOnError": true, "noFallthroughCasesInSwitch": false, "noImplicitAny": false, "noImplicitReturns": false, "noImplicitThis": false, "noImplicitUseStrict": false, "noLib": false, "noResolve": false, "noUnusedLocals": false, "noUnusedParameters": false, "preserveConstEnums": false, "removeComments": false, "skipDefaultLibCheck": false, "skipLibCheck": false, "sourceMap": true, "strictNullChecks": false, "stripInternal": false, "suppressExcessPropertyErrors": false, "suppressImplicitAnyIndexErrors": false, "target": 1 },
2352+
typeAcquisition: { "include": [] }
2353+
}]);
2354+
2355+
let knownProjects = projectService.synchronizeProjectList([]);
2356+
host.reloadFS([libFile, site]);
2357+
host.triggerFileWatcherCallback(configFile.path);
2358+
2359+
knownProjects = projectService.synchronizeProjectList(map(knownProjects, proj => proj.info));
2360+
});
23352361
});
23362362

23372363
describe("Proper errors", () => {

src/server/project.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,10 +1134,12 @@ namespace ts.server {
11341134
this.typeRootsWatchers = undefined;
11351135
}
11361136

1137-
this.directoriesWatchedForWildcards.forEach(watcher => {
1138-
watcher.close();
1139-
});
1140-
this.directoriesWatchedForWildcards = undefined;
1137+
if (this.directoriesWatchedForWildcards) {
1138+
this.directoriesWatchedForWildcards.forEach(watcher => {
1139+
watcher.close();
1140+
});
1141+
this.directoriesWatchedForWildcards = undefined;
1142+
}
11411143

11421144
this.stopWatchingDirectory();
11431145
}

0 commit comments

Comments
 (0)