├── .gitignore ├── spec └── remember-session-spec.coffee ├── package.json ├── LICENSE.md ├── README.md └── lib └── remember-session.coffee /.gitignore: -------------------------------------------------------------------------------- 1 | package.json 2 | npm-debug.log -------------------------------------------------------------------------------- /spec/remember-session-spec.coffee: -------------------------------------------------------------------------------- 1 | RememberFolder = require '../lib/remember-session' 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "remember-session", 3 | "main": "./lib/remember-session", 4 | "version": "0.5.1", 5 | "description": "A simple package to make Atom remember your previous session", 6 | "repository": "https://github.com/hampustagerud/atom-remember-session", 7 | "license": "MIT", 8 | "engines": { 9 | "atom": ">0.50.0" 10 | }, 11 | "dependencies": {} 12 | } 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Permission is hereby granted, free of charge, 4 | to any person obtaining a copy of this software 5 | and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, 8 | modify, merge, publish, distribute, sublicense, and/or 9 | sell copies of the Software, and to permit persons to whom 10 | the Software is furnished to do so, subject to the 11 | following conditions: 12 | 13 | The above copyright notice and this permission notice shall 14 | be included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | THIS PACKAGE IS NOT BEING DEVELOPED ANYMORE AS THE ATOM EDITOR ITSELF NOW HAS THE SAME FUNCTIONALITY AND THIS PLUGIN WAS WRITTEN FOR A PREVIOUS VERSION OF ATOM. THIS PACKAGE IS NOT BEING SUPPORTED BY THE NEW ATOM VERSIONS AND WILL NOT WORK AT ALL! 2 | === 3 | For everyone who used this and wanted an update: I wanted to write something new and improved but this project is not needed anymore. Atom has now built-in functionality for this and they are probably doing it smoother. I created this project when I first got access to the Atom beta and it didn´t save my windows, workfolders or tabs. I wanted something that did this and while this was not the best solution it worked somewhat. Back then Atom was not entirely open sourced and the documentation was not very throughout so this became a very "hackish" solution to my problem by basically implementing basic website logic into the package. 4 | 5 | Anyway, I hope some people enjoyed this while it still worked and to all of you who have been frustrated with its inability to work with the newer versions of Atom I offer my deepest apologies. Developing this package was a great learning experience for me and my first contribution to any online project really but there´s no need for this package and therefore I feel that spending more time on this would be a waste! Thank you all. 6 | 7 | ## Remember Session 8 | 9 | A simple package to save your session when you close Atom. 10 | Based on 11 | [AbeEstradas remember-window](https://github.com/AbeEstrada/atom-remember-window) 12 | 13 | ### Install 14 | `apm install remember-session` 15 | 16 | ### Features 17 | * Saves window location, size along with tree-view width 18 | * Saves the project path and redirects your next session to that path 19 | * Stores all your open tabs and which tab was selected 20 | 21 | ### Current limitations (to be implemented): 22 | * Only the session from the window closed last is saved at the moment 23 | * Only the active pane is saved 24 | * ~~Selected tab is not saved~~ (implemented as of 0.4.0) 25 | 26 | ### Changelog 27 | * Version 0.5.1 28 | - Fixed a bug that caused Atom to not quit properly 29 | * Version 0.5.0 30 | - Fixed bugs that broke all functionality 31 | * Version 0.4.0 32 | + Package now remembers which tab was active 33 | + Package now handles opening multiple projects better 34 | (still only saves the one closed last) 35 | - Fixed a bug where tabs wasn't reopened 36 | - Crashes should not affect the functionality at the next restart 37 | (saves will probably be lost but a bug prevented new saves after a crash) 38 | - Opening new files from the tree view should now work properly again 39 | * Version 0.3.0 40 | + Fixed some more bugs 41 | * Version 0.2.0 42 | + Fixed some bugs 43 | * Version 0.1.0 44 | + Initial commit 45 | -------------------------------------------------------------------------------- /lib/remember-session.coffee: -------------------------------------------------------------------------------- 1 | {$} = require 'atom' 2 | 3 | module.exports = 4 | activate: (state) -> 5 | attachListeners() 6 | 7 | if atom.project.getPath()? 8 | restoreDimensions() 9 | return 10 | 11 | if atom.config.get('remember-session.path')? or atom.config.get('remember-session.tabs')? 12 | restoreSession() 13 | atom.workspaceView.on('pane:active-item-changed', selectTab) 14 | $(window).on 'ready', -> restoreTreeView() 15 | $(window).on 'ready', -> restoreTabs() 16 | 17 | attachListeners = -> 18 | console.log 'Attatch listeners' 19 | $(window).on 'resize', -> saveDimensions() 20 | $(window).on 'beforeunload', -> saveSession() 21 | 22 | saveDimensions = -> 23 | console.log 'Save dimensions' 24 | {x, y, width, height} = atom.getWindowDimensions() 25 | treeWidth = $('.tree-view-resizer').width() 26 | 27 | atom.config.set('remember-session.x', x) 28 | atom.config.set('remember-session.y', y) 29 | if width > 0 30 | atom.config.set('remember-session.width', width) 31 | if height > 0 32 | atom.config.set('remember-session.height', height) 33 | atom.config.set('remember-session.treeWidth', treeWidth) 34 | $(window).off 'beforeunload', -> saveSession() 35 | 36 | saveSession = -> 37 | console.log 'Save session' 38 | if atom.project.getPath()? 39 | atom.config.set('remember-session.path', atom.project.getPath()) 40 | atom.config.set('remember-session.x', atom.getWindowDimensions().x) 41 | atom.config.set('remember-session.y', atom.getWindowDimensions().y) 42 | 43 | tabs = '' 44 | selTab = 0 45 | atom.workspace.eachEditor((editor) -> 46 | if editor.getPath()? 47 | tabs += "&&" + editor.getPath() 48 | else 49 | return true 50 | ) 51 | selectedTab = 0 52 | $('.tab-bar').children('li').each(()-> 53 | if $(this).hasClass('active') 54 | atom.config.set('remember-session.selectedTab', selectedTab) 55 | selectedTab++ 56 | ) 57 | tabs = tabs.substr(2) 58 | atom.config.set('remember-session.tabs', tabs) 59 | return true 60 | 61 | restoreSession = -> 62 | console.log 'Restore session' 63 | if (path = atom.config.get('remember-session.path'))? and path isnt '' 64 | atom.project.setPath(atom.config.get('remember-session.path')) 65 | atom.config.set('remember-session.path', '') 66 | restoreDimensions() 67 | 68 | restoreDimensions = -> 69 | console.log 'Restore dimensions' 70 | {x, y, width, height, path} = atom.config.get('remember-session') 71 | atom.setWindowDimensions 72 | 'x': x 73 | 'y': y 74 | 'width': width 75 | 'height': height 76 | 77 | restoreTabs = -> 78 | console.log 'Restore tabs' 79 | tabs = atom.config.get('remember-session.tabs').split('&&') 80 | for tab in tabs 81 | atom.workspace.open(tab) 82 | $(window).off 'ready', -> restoreTabs() 83 | 84 | selectedIndex = 0 85 | selectTab = (event, item) -> 86 | console.log 'Select tab' 87 | tabs = atom.config.get('remember-session.tabs').split('&&').clean('') 88 | if tabs.length > 0 and !item.getPath()? 89 | atom.workspace.getActivePane().destroyItem(item) 90 | if atom.workspace.getActiveEditor()? and atom.workspace.getActiveEditor().getPath() == tabs[tabs.length - 1] 91 | $('.tab-bar').children('li').each(()-> 92 | selectedTab = atom.config.get('remember-session.selectedTab') 93 | if selectedIndex == selectedTab 94 | $(this).addClass('active') 95 | else 96 | $(this).removeClass('active') 97 | selectedIndex++ 98 | ) 99 | selectedIndex = -1 100 | $('.item-views').children('div').each(()-> 101 | selectedTab = atom.config.get('remember-session.selectedTab') 102 | if selectedIndex == selectedTab 103 | $(this).css('display', 'flex') 104 | else 105 | $(this).css('display', 'none') 106 | selectedIndex++ 107 | ) 108 | 109 | atom.config.set('remember-session.selectedTab', '') 110 | atom.config.set('remember-session.tabs', '') 111 | atom.workspaceView.off('pane:active-item-changed', selectTab) 112 | 113 | restoreTreeView = -> 114 | console.log 'Restore treeview' 115 | treeWidth = atom.config.get('remember-session.treeWidth') 116 | $('.tree-view-resizer').width(treeWidth) 117 | $(window).off 'ready', -> restoreTreeView() 118 | 119 | Array.prototype.clean = (deleteValue) -> 120 | for i in [0..this.length] 121 | if (this[i] == deleteValue) 122 | this.splice(i, 1); 123 | i--; 124 | return this; 125 | --------------------------------------------------------------------------------