denieler / save-workspace-atom-plugin

If you work with few projects same time this plugin give you the opportunity to change your workspace faster. Save your workspace, all your opened tabs, cursor position, etc. for each task you are working with.
MIT License
23 stars 5 forks source link

Crashes if more than two panes #10

Closed davelnewton closed 7 years ago

davelnewton commented 7 years ago

Latest Atom (1.12.7) and plugin.

If I have more than two panes the plugin pukes with the stack trace below.

I suspect the pane-saving code needs to be more recursive as well, but I don't know the Atom pane API at all--I'll check it out today or tomorrow to see if I can resolve this on my own and provide a PR.

Uncaught TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
/Users/dnewton/.atom/packages/save-workspace/lib/models/workspace.js:92
Hide Stack Trace
TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
    at Workspace.__savePaneTabs (/Users/dnewton/.atom/packages/save-workspace/lib/models/workspace.js:92:27)
    at Workspace.save (/Users/dnewton/.atom/packages/save-workspace/lib/models/workspace.js:43:25)
    at Save.<anonymous> (/Users/dnewton/.atom/packages/save-workspace/lib/commands/save.js:18:22)
    at InputWorkspaceNameView.cancelled (/Users/dnewton/.atom/packages/save-workspace/lib/input-workspace-name-view.js:52:10)
    at InputWorkspaceNameView.module.exports.SelectListView.cancel (/Users/dnewton/.atom/packages/save-workspace/node_modules/atom-space-pen-views/lib/select-list-view.js:263:14)
    at InputWorkspaceNameView.module.exports.SelectListView.confirmSelection (/Users/dnewton/.atom/packages/save-workspace/node_modules/atom-space-pen-views/lib/select-list-view.js:340:21)
    at space-pen-div.atom.commands.add.core:confirm (/Users/dnewton/.atom/packages/save-workspace/node_modules/atom-space-pen-views/lib/select-list-view.js:109:19)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:259:29)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:59
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:587:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:382:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:106:36)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:59)
davelnewton commented 7 years ago

There are a number of issues causing this, primary issue seems to be the introduction of a PaneAxis class. I have partial workarounds (and some horrendous dupe code because I don't know the Atom APIs at all) in my fork, https://github.com/davelnewton/save-workspace-atom-plugin, if you're interested in taking a look at my WIP.

TODO: De-dupe the code, and fix it properly, because right now restoring the workspace is creating an entirely new pane into which all things are stuck. It's maybe 65% viable.

davelnewton commented 7 years ago

It's now closer to 85% viable. I refactored out much of the duped code and the saving/restoring is largely functional. I haven't tested strongly for various orientation combinations yet.

denieler commented 7 years ago

@davelnewton I've merged your PR, seems it works now, so I'm closing issue. Thank you very much!

davelnewton commented 7 years ago

@denieler Great; I think there may be some edge cases that make it blow up but I haven't had a chance to revisit this yet. Sorry!