{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/643","repository_url":"https://api.github.com/repos/Microsoft/vscode","labels_url":"https://api.github.com/repos/Microsoft/vscode/issues/643/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/vscode/issues/643/comments","events_url":"https://api.github.com/repos/Microsoft/vscode/issues/643/events","html_url":"https://github.com/Microsoft/vscode/issues/643","id":118898021,"number":643,"title":"API: No way to find out that an editor has closed","user":{"login":"bpasero","id":900690,"avatar_url":"https://avatars.githubusercontent.com/u/900690?v=3","gravatar_id":"","url":"https://api.github.com/users/bpasero","html_url":"https://github.com/bpasero","followers_url":"https://api.github.com/users/bpasero/followers","following_url":"https://api.github.com/users/bpasero/following{/other_user}","gists_url":"https://api.github.com/users/bpasero/gists{/gist_id}","starred_url":"https://api.github.com/users/bpasero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpasero/subscriptions","organizations_url":"https://api.github.com/users/bpasero/orgs","repos_url":"https://api.github.com/users/bpasero/repos","events_url":"https://api.github.com/users/bpasero/events{/privacy}","received_events_url":"https://api.github.com/users/bpasero/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/vscode/labels/api","name":"api","color":"1d76db"},{"url":"https://api.github.com/repos/Microsoft/vscode/labels/feature-request","name":"feature-request","color":"bfe5bf"}],"state":"closed","locked":false,"assignee":{"login":"jrieken","id":1794099,"avatar_url":"https://avatars.githubusercontent.com/u/1794099?v=3","gravatar_id":"","url":"https://api.github.com/users/jrieken","html_url":"https://github.com/jrieken","followers_url":"https://api.github.com/users/jrieken/followers","following_url":"https://api.github.com/users/jrieken/following{/other_user}","gists_url":"https://api.github.com/users/jrieken/gists{/gist_id}","starred_url":"https://api.github.com/users/jrieken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrieken/subscriptions","organizations_url":"https://api.github.com/users/jrieken/orgs","repos_url":"https://api.github.com/users/jrieken/repos","events_url":"https://api.github.com/users/jrieken/events{/privacy}","received_events_url":"https://api.github.com/users/jrieken/received_events","type":"User","site_admin":false},"assignees":[{"login":"jrieken","id":1794099,"avatar_url":"https://avatars.githubusercontent.com/u/1794099?v=3","gravatar_id":"","url":"https://api.github.com/users/jrieken","html_url":"https://github.com/jrieken","followers_url":"https://api.github.com/users/jrieken/followers","following_url":"https://api.github.com/users/jrieken/following{/other_user}","gists_url":"https://api.github.com/users/jrieken/gists{/gist_id}","starred_url":"https://api.github.com/users/jrieken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrieken/subscriptions","organizations_url":"https://api.github.com/users/jrieken/orgs","repos_url":"https://api.github.com/users/jrieken/repos","events_url":"https://api.github.com/users/jrieken/events{/privacy}","received_events_url":"https://api.github.com/users/jrieken/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Microsoft/vscode/milestones/29","html_url":"https://github.com/Microsoft/vscode/milestones/October%202016","labels_url":"https://api.github.com/repos/Microsoft/vscode/milestones/29/labels","id":2019000,"number":29,"title":"October 2016","description":null,"creator":{"login":"weinand","id":1898161,"avatar_url":"https://avatars.githubusercontent.com/u/1898161?v=3","gravatar_id":"","url":"https://api.github.com/users/weinand","html_url":"https://github.com/weinand","followers_url":"https://api.github.com/users/weinand/followers","following_url":"https://api.github.com/users/weinand/following{/other_user}","gists_url":"https://api.github.com/users/weinand/gists{/gist_id}","starred_url":"https://api.github.com/users/weinand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weinand/subscriptions","organizations_url":"https://api.github.com/users/weinand/orgs","repos_url":"https://api.github.com/users/weinand/repos","events_url":"https://api.github.com/users/weinand/events{/privacy}","received_events_url":"https://api.github.com/users/weinand/received_events","type":"User","site_admin":false},"open_issues":141,"closed_issues":115,"state":"open","created_at":"2016-09-21T11:16:13Z","updated_at":"2016-10-13T13:43:40Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-11-25T18:37:08Z","updated_at":"2016-10-13T14:34:23Z","closed_at":"2016-10-13T08:40:40Z","body":"For the VS Code API tests I have a clean up function that signals that it is done when all editors are closed. Currently the solution is hacky, it needs to install a setInterval to periodically check on the `vscode.window.visibleTextEditors` property to eventually become 0 (see https://github.com/Microsoft/vscode/blob/master/extensions/vscode-api-tests/src/utils.ts#L52).\r\n\r\nThe issue is that the `window.onDidChangeActiveTextEditor` event is not good enough for testing on the visible text editors as shown by the following test:\r\n\r\n```\r\ntest('visibleTextEditors', () => {\r\n\treturn workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {\r\n\t\treturn window.showTextDocument(doc).then((editor) => {\r\n\t\t\treturn new Promise((c, e) => {\r\n\t\t\t\tconst listener = window.onDidChangeActiveTextEditor(d => {\r\n\t\t\t\t\tconsole.log('editor is null?: ' + !d);\r\n\t\t\t\t\tif (window.visibleTextEditors.length > 0) {\r\n\t\t\t\t\t\tconsole.log('visibleTextEditors count is: ' + window.visibleTextEditors.length);\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tlistener.dispose();\r\n\t\t\t\t\tc();\r\n\t\t\t\t});\r\n\r\n\t\t\t\tcommands.executeCommand('workbench.action.closeAllEditors').then(null, e);\r\n\t\t\t});\r\n\t\t});\r\n\t});\r\n});\r\n```\r\n\r\nThe value passed in from the event is null as expected because I am running the close all editors action. However, `window.visibleTextEditors.length` is still 1 at that point."},"comment":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/comments/253531382","html_url":"https://github.com/Microsoft/vscode/issues/643#issuecomment-253531382","issue_url":"https://api.github.com/repos/Microsoft/vscode/issues/643","id":253531382,"user":{"login":"joaomoreno","id":22350,"avatar_url":"https://avatars.githubusercontent.com/u/22350?v=3","gravatar_id":"","url":"https://api.github.com/users/joaomoreno","html_url":"https://github.com/joaomoreno","followers_url":"https://api.github.com/users/joaomoreno/followers","following_url":"https://api.github.com/users/joaomoreno/following{/other_user}","gists_url":"https://api.github.com/users/joaomoreno/gists{/gist_id}","starred_url":"https://api.github.com/users/joaomoreno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaomoreno/subscriptions","organizations_url":"https://api.github.com/users/joaomoreno/orgs","repos_url":"https://api.github.com/users/joaomoreno/repos","events_url":"https://api.github.com/users/joaomoreno/events{/privacy}","received_events_url":"https://api.github.com/users/joaomoreno/received_events","type":"User","site_admin":false},"created_at":"2016-10-13T14:34:23Z","updated_at":"2016-10-13T14:34:23Z","body":"Seems to work like a charm. 🎆 "}}
{"actor":{"display_login":"joaomoreno"}}