{"action":"created","comment":{"url":"https://api.github.com/repos/adobe/brackets/pulls/comments/87972475","pull_request_review_id":8560101,"id":87972475,"diff_hunk":"@@ -830,6 +856,56 @@ define(function (require, exports, module) {\n             }\n         });\n     };\n+    \n+    /**\n+     * This stores file system events emitted by watchers that were not yet processed\n+     */\n+    var _cachedFileSystemEvents = [];\n+    \n+    /**\n+     * Debounced function to process emitted file system events\n+     * for cases when there's a lot of fs events emitted in a very short period of time\n+     */\n+    _processCachedFileSystemEvents = _.debounce(function () {\n+        // we need to reduce _cachedFileSystemEvents not to contain duplicates!\n+        _cachedFileSystemEvents = _cachedFileSystemEvents.reduce(function (result, obj) {\n+            var fullPath = obj.entry ? obj.entry.fullPath : null;\n+            // merge added & removed\n+            if (result[fullPath] && obj.isDirectory) {\n+                obj.added = obj.added.concat(result[fullPath].added);\n+                obj.removed = obj.removed.concat(result[fullPath].removed);\n+            }\n+            // use the latest event as base\n+            result[fullPath] = obj;\n+            return result;\n+        }, {});\n+        _.forEach(_cachedFileSystemEvents, function (obj) {\n+            _fileSystemChangeHandler(obj.event, obj.entry, obj.added, obj.removed);\n+        });\n+        _cachedFileSystemEvents = [];","path":"src/search/FindInFiles.js","position":248,"original_position":248,"commit_id":"69c3243b17cf36f1e1c8c36299f31a3fbb83ffda","original_commit_id":"69c3243b17cf36f1e1c8c36299f31a3fbb83ffda","user":{"login":"zaggino","id":1067319,"avatar_url":"https://avatars.githubusercontent.com/u/1067319?v=3","gravatar_id":"","url":"https://api.github.com/users/zaggino","html_url":"https://github.com/zaggino","followers_url":"https://api.github.com/users/zaggino/followers","following_url":"https://api.github.com/users/zaggino/following{/other_user}","gists_url":"https://api.github.com/users/zaggino/gists{/gist_id}","starred_url":"https://api.github.com/users/zaggino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaggino/subscriptions","organizations_url":"https://api.github.com/users/zaggino/orgs","repos_url":"https://api.github.com/users/zaggino/repos","events_url":"https://api.github.com/users/zaggino/events{/privacy}","received_events_url":"https://api.github.com/users/zaggino/received_events","type":"User","site_admin":false},"body":"`debounce` just wraps a function and keeps postponing its execution until the wrapper stops to be called for the timeout time. But once the wrapped function is executed, all happens totally sync so the code is safe. I've used this pattern a few times before.","created_at":"2016-11-15T09:03:49Z","updated_at":"2016-11-15T09:03:49Z","html_url":"https://github.com/adobe/brackets/pull/12885#discussion_r87972475","pull_request_url":"https://api.github.com/repos/adobe/brackets/pulls/12885","_links":{"self":{"href":"https://api.github.com/repos/adobe/brackets/pulls/comments/87972475"},"html":{"href":"https://github.com/adobe/brackets/pull/12885#discussion_r87972475"},"pull_request":{"href":"https://api.github.com/repos/adobe/brackets/pulls/12885"}}},"pull_request":{"url":"https://api.github.com/repos/adobe/brackets/pulls/12885","id":92906644,"html_url":"https://github.com/adobe/brackets/pull/12885","diff_url":"https://github.com/adobe/brackets/pull/12885.diff","patch_url":"https://github.com/adobe/brackets/pull/12885.patch","issue_url":"https://api.github.com/repos/adobe/brackets/issues/12885","number":12885,"state":"open","locked":false,"title":"improvements to file system events processing for search","user":{"login":"zaggino","id":1067319,"avatar_url":"https://avatars.githubusercontent.com/u/1067319?v=3","gravatar_id":"","url":"https://api.github.com/users/zaggino","html_url":"https://github.com/zaggino","followers_url":"https://api.github.com/users/zaggino/followers","following_url":"https://api.github.com/users/zaggino/following{/other_user}","gists_url":"https://api.github.com/users/zaggino/gists{/gist_id}","starred_url":"https://api.github.com/users/zaggino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaggino/subscriptions","organizations_url":"https://api.github.com/users/zaggino/orgs","repos_url":"https://api.github.com/users/zaggino/repos","events_url":"https://api.github.com/users/zaggino/events{/privacy}","received_events_url":"https://api.github.com/users/zaggino/received_events","type":"User","site_admin":false},"body":"Hi guys, I've reported elsewhere that my db dump script crashes both brackets (white-screen) and also brackets-electron. This is the work done to fix that (and I can confirm that with this fix there's no crash when running my script anymore) - it's not final and I'd like to have it reviewed before working on little things as docs and similar.\r\n\r\nThere're two main things, first aggregate duplicate events and debounce for a short while before processing. My script quickly deletes and creates back a lot of stuff, before this change some of the directories were removed and added back to search multiple times. With debouncing it's only once after script is done.\r\n\r\nSecond, no less important thing is fixing calls to `filesChanged` and `filesRemoved` functions. In case of my script these two were called about 1000 times with an array of size 1 which cause a lot of trouble for IPC connection in electron and socket connection in regular brackets. With the fix these are now properly called.\r\n\r\nMarking this as high-priority because it fixes brackets completely crashing in some cases.","created_at":"2016-11-09T05:16:58Z","updated_at":"2016-11-15T09:03:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2cdf4f9fd9c095250ebbc1e98ad50849bc9a431","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/adobe/brackets/pulls/12885/commits","review_comments_url":"https://api.github.com/repos/adobe/brackets/pulls/12885/comments","review_comment_url":"https://api.github.com/repos/adobe/brackets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adobe/brackets/issues/12885/comments","statuses_url":"https://api.github.com/repos/adobe/brackets/statuses/69c3243b17cf36f1e1c8c36299f31a3fbb83ffda","head":{"label":"adobe:zaggino/fs-improvements","ref":"zaggino/fs-improvements","sha":"69c3243b17cf36f1e1c8c36299f31a3fbb83ffda","user":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"repo":{"id":2935735,"name":"brackets","full_name":"adobe/brackets","owner":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adobe/brackets","description":"An open source code editor for the web, written in JavaScript, HTML and CSS.","fork":false,"url":"https://api.github.com/repos/adobe/brackets","forks_url":"https://api.github.com/repos/adobe/brackets/forks","keys_url":"https://api.github.com/repos/adobe/brackets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adobe/brackets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adobe/brackets/teams","hooks_url":"https://api.github.com/repos/adobe/brackets/hooks","issue_events_url":"https://api.github.com/repos/adobe/brackets/issues/events{/number}","events_url":"https://api.github.com/repos/adobe/brackets/events","assignees_url":"https://api.github.com/repos/adobe/brackets/assignees{/user}","branches_url":"https://api.github.com/repos/adobe/brackets/branches{/branch}","tags_url":"https://api.github.com/repos/adobe/brackets/tags","blobs_url":"https://api.github.com/repos/adobe/brackets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adobe/brackets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adobe/brackets/git/refs{/sha}","trees_url":"https://api.github.com/repos/adobe/brackets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adobe/brackets/statuses/{sha}","languages_url":"https://api.github.com/repos/adobe/brackets/languages","stargazers_url":"https://api.github.com/repos/adobe/brackets/stargazers","contributors_url":"https://api.github.com/repos/adobe/brackets/contributors","subscribers_url":"https://api.github.com/repos/adobe/brackets/subscribers","subscription_url":"https://api.github.com/repos/adobe/brackets/subscription","commits_url":"https://api.github.com/repos/adobe/brackets/commits{/sha}","git_commits_url":"https://api.github.com/repos/adobe/brackets/git/commits{/sha}","comments_url":"https://api.github.com/repos/adobe/brackets/comments{/number}","issue_comment_url":"https://api.github.com/repos/adobe/brackets/issues/comments{/number}","contents_url":"https://api.github.com/repos/adobe/brackets/contents/{+path}","compare_url":"https://api.github.com/repos/adobe/brackets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adobe/brackets/merges","archive_url":"https://api.github.com/repos/adobe/brackets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adobe/brackets/downloads","issues_url":"https://api.github.com/repos/adobe/brackets/issues{/number}","pulls_url":"https://api.github.com/repos/adobe/brackets/pulls{/number}","milestones_url":"https://api.github.com/repos/adobe/brackets/milestones{/number}","notifications_url":"https://api.github.com/repos/adobe/brackets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adobe/brackets/labels{/name}","releases_url":"https://api.github.com/repos/adobe/brackets/releases{/id}","deployments_url":"https://api.github.com/repos/adobe/brackets/deployments","created_at":"2011-12-07T21:14:40Z","updated_at":"2016-11-15T05:37:57Z","pushed_at":"2016-11-14T03:25:58Z","git_url":"git://github.com/adobe/brackets.git","ssh_url":"git@github.com:adobe/brackets.git","clone_url":"https://github.com/adobe/brackets.git","svn_url":"https://github.com/adobe/brackets","homepage":"http://brackets.io","size":210644,"stargazers_count":26375,"watchers_count":26375,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5574,"mirror_url":null,"open_issues_count":1794,"forks":5574,"open_issues":1794,"watchers":26375,"default_branch":"master"}},"base":{"label":"adobe:master","ref":"master","sha":"150c657acbac5c77bc83d85257b1862f25c783b7","user":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"repo":{"id":2935735,"name":"brackets","full_name":"adobe/brackets","owner":{"login":"adobe","id":476009,"avatar_url":"https://avatars.githubusercontent.com/u/476009?v=3","gravatar_id":"","url":"https://api.github.com/users/adobe","html_url":"https://github.com/adobe","followers_url":"https://api.github.com/users/adobe/followers","following_url":"https://api.github.com/users/adobe/following{/other_user}","gists_url":"https://api.github.com/users/adobe/gists{/gist_id}","starred_url":"https://api.github.com/users/adobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adobe/subscriptions","organizations_url":"https://api.github.com/users/adobe/orgs","repos_url":"https://api.github.com/users/adobe/repos","events_url":"https://api.github.com/users/adobe/events{/privacy}","received_events_url":"https://api.github.com/users/adobe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adobe/brackets","description":"An open source code editor for the web, written in JavaScript, HTML and CSS.","fork":false,"url":"https://api.github.com/repos/adobe/brackets","forks_url":"https://api.github.com/repos/adobe/brackets/forks","keys_url":"https://api.github.com/repos/adobe/brackets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adobe/brackets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adobe/brackets/teams","hooks_url":"https://api.github.com/repos/adobe/brackets/hooks","issue_events_url":"https://api.github.com/repos/adobe/brackets/issues/events{/number}","events_url":"https://api.github.com/repos/adobe/brackets/events","assignees_url":"https://api.github.com/repos/adobe/brackets/assignees{/user}","branches_url":"https://api.github.com/repos/adobe/brackets/branches{/branch}","tags_url":"https://api.github.com/repos/adobe/brackets/tags","blobs_url":"https://api.github.com/repos/adobe/brackets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adobe/brackets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adobe/brackets/git/refs{/sha}","trees_url":"https://api.github.com/repos/adobe/brackets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adobe/brackets/statuses/{sha}","languages_url":"https://api.github.com/repos/adobe/brackets/languages","stargazers_url":"https://api.github.com/repos/adobe/brackets/stargazers","contributors_url":"https://api.github.com/repos/adobe/brackets/contributors","subscribers_url":"https://api.github.com/repos/adobe/brackets/subscribers","subscription_url":"https://api.github.com/repos/adobe/brackets/subscription","commits_url":"https://api.github.com/repos/adobe/brackets/commits{/sha}","git_commits_url":"https://api.github.com/repos/adobe/brackets/git/commits{/sha}","comments_url":"https://api.github.com/repos/adobe/brackets/comments{/number}","issue_comment_url":"https://api.github.com/repos/adobe/brackets/issues/comments{/number}","contents_url":"https://api.github.com/repos/adobe/brackets/contents/{+path}","compare_url":"https://api.github.com/repos/adobe/brackets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adobe/brackets/merges","archive_url":"https://api.github.com/repos/adobe/brackets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adobe/brackets/downloads","issues_url":"https://api.github.com/repos/adobe/brackets/issues{/number}","pulls_url":"https://api.github.com/repos/adobe/brackets/pulls{/number}","milestones_url":"https://api.github.com/repos/adobe/brackets/milestones{/number}","notifications_url":"https://api.github.com/repos/adobe/brackets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adobe/brackets/labels{/name}","releases_url":"https://api.github.com/repos/adobe/brackets/releases{/id}","deployments_url":"https://api.github.com/repos/adobe/brackets/deployments","created_at":"2011-12-07T21:14:40Z","updated_at":"2016-11-15T05:37:57Z","pushed_at":"2016-11-14T03:25:58Z","git_url":"git://github.com/adobe/brackets.git","ssh_url":"git@github.com:adobe/brackets.git","clone_url":"https://github.com/adobe/brackets.git","svn_url":"https://github.com/adobe/brackets","homepage":"http://brackets.io","size":210644,"stargazers_count":26375,"watchers_count":26375,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5574,"mirror_url":null,"open_issues_count":1794,"forks":5574,"open_issues":1794,"watchers":26375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adobe/brackets/pulls/12885"},"html":{"href":"https://github.com/adobe/brackets/pull/12885"},"issue":{"href":"https://api.github.com/repos/adobe/brackets/issues/12885"},"comments":{"href":"https://api.github.com/repos/adobe/brackets/issues/12885/comments"},"review_comments":{"href":"https://api.github.com/repos/adobe/brackets/pulls/12885/comments"},"review_comment":{"href":"https://api.github.com/repos/adobe/brackets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adobe/brackets/pulls/12885/commits"},"statuses":{"href":"https://api.github.com/repos/adobe/brackets/statuses/69c3243b17cf36f1e1c8c36299f31a3fbb83ffda"}}}}
{"actor":{"display_login":"zaggino"}}