{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/42072073","id":42072073,"diff_hunk":"@@ -615,9 +722,24 @@ namespace ts.server {\n             this.configuredProjects = configuredProjects;\r\n         }\r\n \r\n-        removeConfiguredProject(project: Project) {\r\n-            project.projectFileWatcher.close();\r\n-            this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);\r\n+        removeProject(project: Project) {\r\n+            this.log(\"remove project: \" + project.getRootFiles().toString());\r\n+            if (project.isConfiguredProject()) {\r\n+                project.projectFileWatcher.close();\r\n+                project.directoryWatcher.close();\r\n+                this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);\r\n+            }\r\n+            else {\r\n+                for (let directory of project.directoriesWatchedForTsconfig) {\r\n+                    // if the ref count for this directory watcher drops to 0, it's time to close it\r\n+                    if (!(--project.projectService.directoryWatchersRefCount[directory])) {\r\n+                        this.log(\"Close directory watcher for: \" + directory);\r\n+                        project.projectService.directoryWatchersForTsconfig[directory].close();\r\n+                        project.projectService.directoryWatchersForTsconfig[directory] = undefined;\r","path":"src/server/editorServices.ts","position":293,"original_position":293,"commit_id":"fcfc25eeb040390492716626757274c945ebd47f","original_commit_id":"fcfc25eeb040390492716626757274c945ebd47f","user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"body":"possibly use delete","created_at":"2015-10-15T00:35:11Z","updated_at":"2015-10-15T00:35:11Z","html_url":"https://github.com/Microsoft/TypeScript/pull/5127#discussion_r42072073","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/42072073"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/5127#discussion_r42072073"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127","id":46848375,"html_url":"https://github.com/Microsoft/TypeScript/pull/5127","diff_url":"https://github.com/Microsoft/TypeScript/pull/5127.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/5127.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5127","number":5127,"state":"open","locked":false,"title":"Add directory watcher for tsserver and tsc","user":{"login":"zhengbli","id":1171301,"avatar_url":"https://avatars.githubusercontent.com/u/1171301?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengbli","html_url":"https://github.com/zhengbli","followers_url":"https://api.github.com/users/zhengbli/followers","following_url":"https://api.github.com/users/zhengbli/following{/other_user}","gists_url":"https://api.github.com/users/zhengbli/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengbli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengbli/subscriptions","organizations_url":"https://api.github.com/users/zhengbli/orgs","repos_url":"https://api.github.com/users/zhengbli/repos","events_url":"https://api.github.com/users/zhengbli/events{/privacy}","received_events_url":"https://api.github.com/users/zhengbli/received_events","type":"User","site_admin":false},"body":"**This PR contains the following changes**:\r\n1. Unify the file / directory watcher functions in tsc and tsserver;\r\n2. For inferred projects, add the ability to detect newly added `tsconfig.json` files in from the same directory up to the root path;\r\n3. For configured projects, add the ability to detect implicitly added/removed source files (e.g., when the `tsconfig.json` file doesn't have a `files` array, and source files are added to or removed from the directory) from the same directory down recursively. (Fix #5076, #4643)\r\n4. For `tsconfig.json` file without a `files` array, also added support to detect file addition / removal under `tsc --watch`. (Fix #4553)\r\n\r\n**Points worth notice**:\r\nInferred projects and configured projects have different kinds of directory watchers:\r\n1. For inferred projects, the sole purpose of a directory watcher is to detect newly added `tsconfig.json` files; and the addition normally happens from the current path up. Also, it doesn't matter which project the watcher belongs to, all inferred projects can share one set of watchers if their root files happen to be in the same folder. \r\n2. For configured projects, each project has a recursive directory watcher of the path where its config file is located at. It does matter which project the watcher belongs to.\r\n3. Currently the recursive watchers are supported in Node 4.0 for both OSX and Windows. If the node version is before that, the recursive watcher might not work reliably. ","created_at":"2015-10-05T23:49:19Z","updated_at":"2015-10-15T00:35:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2894e3af88596b96d7b48ad107a9f3b96b75be93","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5127/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/fcfc25eeb040390492716626757274c945ebd47f","head":{"label":"zhengbli:newAddDirectoryWatcher","ref":"newAddDirectoryWatcher","sha":"fcfc25eeb040390492716626757274c945ebd47f","user":{"login":"zhengbli","id":1171301,"avatar_url":"https://avatars.githubusercontent.com/u/1171301?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengbli","html_url":"https://github.com/zhengbli","followers_url":"https://api.github.com/users/zhengbli/followers","following_url":"https://api.github.com/users/zhengbli/following{/other_user}","gists_url":"https://api.github.com/users/zhengbli/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengbli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengbli/subscriptions","organizations_url":"https://api.github.com/users/zhengbli/orgs","repos_url":"https://api.github.com/users/zhengbli/repos","events_url":"https://api.github.com/users/zhengbli/events{/privacy}","received_events_url":"https://api.github.com/users/zhengbli/received_events","type":"User","site_admin":false},"repo":{"id":31636477,"name":"TypeScript","full_name":"zhengbli/TypeScript","owner":{"login":"zhengbli","id":1171301,"avatar_url":"https://avatars.githubusercontent.com/u/1171301?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengbli","html_url":"https://github.com/zhengbli","followers_url":"https://api.github.com/users/zhengbli/followers","following_url":"https://api.github.com/users/zhengbli/following{/other_user}","gists_url":"https://api.github.com/users/zhengbli/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengbli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengbli/subscriptions","organizations_url":"https://api.github.com/users/zhengbli/orgs","repos_url":"https://api.github.com/users/zhengbli/repos","events_url":"https://api.github.com/users/zhengbli/events{/privacy}","received_events_url":"https://api.github.com/users/zhengbli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zhengbli/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":true,"url":"https://api.github.com/repos/zhengbli/TypeScript","forks_url":"https://api.github.com/repos/zhengbli/TypeScript/forks","keys_url":"https://api.github.com/repos/zhengbli/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zhengbli/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zhengbli/TypeScript/teams","hooks_url":"https://api.github.com/repos/zhengbli/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/zhengbli/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/zhengbli/TypeScript/events","assignees_url":"https://api.github.com/repos/zhengbli/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/zhengbli/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/zhengbli/TypeScript/tags","blobs_url":"https://api.github.com/repos/zhengbli/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zhengbli/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zhengbli/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/zhengbli/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zhengbli/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/zhengbli/TypeScript/languages","stargazers_url":"https://api.github.com/repos/zhengbli/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/zhengbli/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/zhengbli/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/zhengbli/TypeScript/subscription","commits_url":"https://api.github.com/repos/zhengbli/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/zhengbli/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/zhengbli/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/zhengbli/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/zhengbli/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/zhengbli/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zhengbli/TypeScript/merges","archive_url":"https://api.github.com/repos/zhengbli/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zhengbli/TypeScript/downloads","issues_url":"https://api.github.com/repos/zhengbli/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/zhengbli/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/zhengbli/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/zhengbli/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zhengbli/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/zhengbli/TypeScript/releases{/id}","created_at":"2015-03-04T03:41:12Z","updated_at":"2015-05-05T17:16:07Z","pushed_at":"2015-10-14T23:57:27Z","git_url":"git://github.com/zhengbli/TypeScript.git","ssh_url":"git@github.com:zhengbli/TypeScript.git","clone_url":"https://github.com/zhengbli/TypeScript.git","svn_url":"https://github.com/zhengbli/TypeScript","homepage":"http://www.typescriptlang.org","size":204601,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"53cff210fd9c08f32764251bf773b8de9c454092","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-10-14T23:47:44Z","pushed_at":"2015-10-15T00:30:36Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":1149045,"stargazers_count":7007,"watchers_count":7007,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":793,"mirror_url":null,"open_issues_count":895,"forks":793,"open_issues":895,"watchers":7007,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/5127"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/5127"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/5127/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/5127/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/fcfc25eeb040390492716626757274c945ebd47f"}}}}