Git Product home page Git Product logo

Comments (14)

mpeterson2 avatar mpeterson2 commented on June 26, 2024

I like the idea, but I'm not sure if this is going to be possible to do. From what I can tell Atom handles separate windows almost like separate applications, so I have no way of knowing whether you are closing the window or closing the application.

The way that I can think of solving this (which I don't believe is possible at the time), would be to save the open projects whenever you open/close a project, and do nothing when you close the application with cmd + q or the Atom -> Quit Atom. I haven't found a way to determine whether you are closing just a window or closing the entire application, so I don't believe there is a very good way to handle this with Atom's current API.

If you have any ideas or interest in implementing them, let me know or send a pull request/update the issue with some useful information!

from save-session.

uberbrady avatar uberbrady commented on June 26, 2024

I've been rolling this around in my head, too.

I was imagining an algorithm something like this (and some of these things won't directly be possible, but I think it could be the right track) -

On Quit, do:

If there is no flag file, add a flag file, truncate the save file to zero bytes.
If there is a flag file, and the flag file is from within the last...minute? or so? then just be prepared to append to it. Else truncate as above.

Now, as each atom 'process' (window?) closes, it follows the above algorithm. Thus it should write the save data to the file, and exit (without closing the file?! Not sure). The end result is a save-file with all of the current open workspaces as Atom was quit.

On Reopen:

Open the save file. For each entry, open that project. Once all of the files are open, delete the flag file.

So, I guess - if you just 'close' one of the windows - you don't do anything.

Another thing to note is that you might be able to wrap the 'flag' and the 'save-file' into just one logical file; not sure.

A problem with this setup would be that, in the event of a crash, you get nothing. That would suck.

If this sounds like a direction that might work, let me know. I don't know anything about developing for Atom, but I'm a pretty seasoned coffeescript developer and should be able to at least take a rough swing at it to get started.

from save-session.

mpeterson2 avatar mpeterson2 commented on June 26, 2024

My thoughts

I think they're pretty similar, but here's my thoughts after reading your's.

Saving

I think open projects could just be saved in ~/.atom/packages/save-session/projects/open-projects.json. I have a few thoughts on how the json could be stored. The first would allow for more to be saved in the future, but I'm not sure if that's to worth it for now.

Json Version 1

The json could just contain a list of open projects that have a key of their path and contain a time value since the last closing. If the project is still open, exclude the time since last closing.

open.json example:

[
    {
        "path": "path/to/closed/project",
        "closeTime": 123456
    },
    {
        "path": "path/to/open/project"
    }
]

Json Version 2

Or, it could just be a map with a key of the project and a value of the time since closed. The time is just undefined if the project is open.

open.json example:

{
  "path/to/closed/project": 123456,
  "path/to/open/project": "undefined"
}

On open

  • Read the json file
  • Overwrite the current project to say it's open
  • Reopen projects if every project contains a closedTime

By only reopening projects if they all contain a closedTime, we avoid restoring projects if the user just opens a new Atom window/project.

On close

  • Read the file
  • Overwrite the current project with a closedTime, to say it's closed
  • Remove all the old projects from the json
  • Rewrite the open-projects.json file

Settings

Everything should be optional, including this feature. How long after a project has closed to be considered open should also be an option. The location of the open-projects.json file should also be a setting.

Developing for Atom

Atom has a pretty simple API, I've never used CoffeeScript before this project, so it was all new to me and I picked it up pretty quickly. The documentation is fairly good, and there is a nice guide for building a simple Atom package.

Anyway, let me know what you think.

from save-session.

prometheas avatar prometheas commented on June 26, 2024

Yea, this is huge. The plugin is frankly incomplete until all open projects can be restored.

from save-session.

uberbrady avatar uberbrady commented on June 26, 2024

Here's another thought I had - you can make it even simpler, perhaps -

Every time you open a project, you append that to the re-opening file.
Every time you close a project, you remove that project from the re-opening file.

On crash or quit - just read that file and open those projects. The problem - in my cursory examination - looked like it was going to be hard to hook in to the close-button on the window, and the close project menu item in the menus. You'd basically want to override those, right? Everything else might stay the same.

from save-session.

mpeterson2 avatar mpeterson2 commented on June 26, 2024

It would be nice to have it that simple, but the problem with that is there is no way that I've found to tell whether you're closing a project or closing Atom itself. I suppose hooking into the UI buttons to close projects would work, but like you said, that's not an easy task to do.

Also if you did this on open, than each project that is opened, will try to open all the projects that are saved in that file. We don't want that to happen.

from save-session.

swrobel avatar swrobel commented on June 26, 2024

I think https://github.com/norio-nomura/restore-windows claims to do this ... perhaps some clues in there

from save-session.

mpeterson2 avatar mpeterson2 commented on June 26, 2024

Looks like it works pretty similar to what's been said on here previously. I think we have the ability to do it, I just don't have the time for it right now unfortunately.

from save-session.

inteist avatar inteist commented on June 26, 2024

+1 having this feature!
Please keep in mind that you can have an open window through CMD SHIFT N too, not just from the command line

from save-session.

Santinell avatar Santinell commented on June 26, 2024

Now with version 0.182 of Atom feature of multiple projects became necessary (Multi root in one window)

from save-session.

dmsimard avatar dmsimard commented on June 26, 2024

Agreed, would love to have this work properly with the Atom feature of multiple root folders in the same window. It only re-opens one of the root folders.

from save-session.

mpeterson2 avatar mpeterson2 commented on June 26, 2024

This should be in Atom core now.

from save-session.

Goddard avatar Goddard commented on June 26, 2024

This feature is still not working in Atom latest build on Windows and Linux. It only works in OSX.

from save-session.

Santinell avatar Santinell commented on June 26, 2024

I thought so too, but after deleting all atom files and installing atom again - it works for me on Linux and Windows

from save-session.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.