{"action":"reopened","issue":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/1757","labels_url":"https://api.github.com/repos/Microsoft/vscode/issues/1757/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/vscode/issues/1757/comments","events_url":"https://api.github.com/repos/Microsoft/vscode/issues/1757/events","html_url":"https://github.com/Microsoft/vscode/issues/1757","id":124672159,"number":1757,"title":"Open previous state upon startup","user":{"login":"TheColorRed","id":1571806,"avatar_url":"https://avatars.githubusercontent.com/u/1571806?v=3","gravatar_id":"","url":"https://api.github.com/users/TheColorRed","html_url":"https://github.com/TheColorRed","followers_url":"https://api.github.com/users/TheColorRed/followers","following_url":"https://api.github.com/users/TheColorRed/following{/other_user}","gists_url":"https://api.github.com/users/TheColorRed/gists{/gist_id}","starred_url":"https://api.github.com/users/TheColorRed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheColorRed/subscriptions","organizations_url":"https://api.github.com/users/TheColorRed/orgs","repos_url":"https://api.github.com/users/TheColorRed/repos","events_url":"https://api.github.com/users/TheColorRed/events{/privacy}","received_events_url":"https://api.github.com/users/TheColorRed/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/vscode/labels/feature-request","name":"feature-request","color":"bfe5bf"}],"state":"open","locked":false,"assignee":{"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},"milestone":{"url":"https://api.github.com/repos/Microsoft/vscode/milestones/8","html_url":"https://github.com/Microsoft/vscode/milestones/Backlog","labels_url":"https://api.github.com/repos/Microsoft/vscode/milestones/8/labels","id":1412124,"number":8,"title":"Backlog","description":"Work not yet planned for a specific release.","creator":{"login":"chrisdias","id":1487073,"avatar_url":"https://avatars.githubusercontent.com/u/1487073?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisdias","html_url":"https://github.com/chrisdias","followers_url":"https://api.github.com/users/chrisdias/followers","following_url":"https://api.github.com/users/chrisdias/following{/other_user}","gists_url":"https://api.github.com/users/chrisdias/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdias/subscriptions","organizations_url":"https://api.github.com/users/chrisdias/orgs","repos_url":"https://api.github.com/users/chrisdias/repos","events_url":"https://api.github.com/users/chrisdias/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdias/received_events","type":"User","site_admin":false},"open_issues":665,"closed_issues":144,"state":"open","created_at":"2015-11-15T10:30:19Z","updated_at":"2016-01-05T16:13:10Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-01-03T21:32:13Z","updated_at":"2016-01-05T16:13:10Z","closed_at":null,"body":"Have the ability to remember the previous state of the editor upon startup.\r\n\r\nI used this with electron:\r\n\r\nstorage.js\r\n\r\n    var app = require('app');\r\n    var fs = require('fs');\r\n    var path = require('path');\r\n    var data = null;\r\n    var dataFilePath = path.join(app.getPath('userData'), 'data.json');\r\n\r\n    function load() {\r\n        if (data !== null) {\r\n            return;\r\n        }\r\n\r\n        if (!fs.existsSync(dataFilePath)) {\r\n            data = {};\r\n            return;\r\n        }\r\n\r\n        data = JSON.parse(fs.readFileSync(dataFilePath, 'utf-8'));\r\n    }\r\n\r\n    function save() {\r\n        fs.writeFileSync(dataFilePath, JSON.stringify(data));\r\n    }\r\n\r\n    exports.set = function (key, value) {\r\n        load();\r\n        data[key] = value;\r\n        save();\r\n    }\r\n\r\n    exports.get = function (key) {\r\n        load();\r\n        var value = null;\r\n        if (key in data) {\r\n            value = data[key];\r\n        }\r\n        return value;\r\n    }\r\n\r\n    exports.unset = function (key) {\r\n        load();\r\n        if (key in data) {\r\n            delete data[key];\r\n            save();\r\n        }\r\n    }\r\n\r\nThen do something like this:\r\n\r\n    var storage = require('storage');\r\n\r\n    app.on('ready', function () {\r\n        // Create the browser window.\r\n        var lastWindowState = storage.get(\"lastWindowState\");\r\n        if (lastWindowState === null) {\r\n            lastWindowState = {\r\n                width: 1024,\r\n                height: 768,\r\n                maximized: false\r\n            }\r\n        }\r\n\r\n        mainWindow = new BrowserWindow({\r\n            x: lastWindowState.x,\r\n            y: lastWindowState.y,\r\n            width: lastWindowState.width,\r\n            height: lastWindowState.height,\r\n            minWidth: 800,\r\n            minHeight: 600\r\n        });\r\n\r\n        mainWindow.on('close', function () {\r\n            var bounds = mainWindow.getBounds();\r\n            storage.set(\"lastWindowState\", {\r\n                x: bounds.x,\r\n                y: bounds.y,\r\n                width: bounds.width,\r\n                height: bounds.height,\r\n                maximized: mainWindow.isMaximized()\r\n            });\r\n        });\r\n    });"}}