Save-Session


#1

Hey, I’ve been searching online for a way to enable save session for Atom considering I used to use it in Sublime. It’s actually kind of annoying to have to reopen all my files/folders every time I start up the editor. I’ve tried installing the save-session and remember-session packages but they’ve been depreciated and added to the core build. Despite them being added, I can’t seem to find the option to enable this anywhere in the settings and I am not sure what the command is to type it into the config.

If somebody could just tell me the command or how exactly to add this feature it would be great, because I don’t think I can continue to use this without that feature. It’s a critical feature.


#2

Atom automatically opens your previous window state when you open the application, unless you have specifically told it otherwise or a package is interfering with the process. You can see which paths will be opened on Atom’s start by looking at .atom/storage/application.json.

What operating system are you using, what sequence are you using to quit Atom, and does the problem persist when you start Atom from the command line with atom --safe?


#3

I have the same issue:

On macOS Sierra 10.12.2:

  1. opening via docked app icon and terminal with and without --safe
  2. I will open a folder (also tried “add project folder”), then type something in the default empty editor; my window will consist of the folder tree in the sidebar and an unsaved, ‘untitled’ editor tab with some content.
  3. Close atom using cmd + Q, no prompt to save unsaved tab
  4. repeat step 1

The result is a new atom window with an empty editor, no sidebar. Thoughts?


#4

Have you looked at the contents of ~/.atom/storage/application.json? Which version of Atom are you using? What are the contents of your ~/.atom/config.cson?


#5

Atom 1.12.8


initially on fresh open:

# ~/.atom/storage/application.json
[]

after losing focus:

# ~/.atom/storage/application.json
[{"initialPaths":["/Users/david/.atom/storage"]}]

reverts to [] on close/open cycle


# ~/.atom/config.cson
"*":
  core:
    projectHome: "/Users/david/drive/projects/github"
    telemetryConsent: "limited"
    themes: [
      "atom-dark-ui"
      "monokai"
    ]
  editor:
    fontSize: 12
    softWrap: true
  "exception-reporting":
    userId: "a9b5a185-45b6-10ff-3d0f-506c7df2ed1e"
  metrics:
    userId: "86a60efba1c49e76d39d8c0311c9ff2ac6c9017e"
  "save-session":
    dataSaveFolder: "/Users/david/.atom/packages/save-session/projects"
  welcome:
    showOnStartup: false
  wordcount:
    noextension: true

#6

Do you close the window before you close the application as described here?


#7

What does it look like right after you close Atom, without opening it again?


#8

Buckle up, we’re in for a wild ride.

  1. Opened atom with $ atom .atom/config.cson
  2. Opened application.json with $ atom .atom/storage/application.json
  3. Confirmed application.json was populated with [{"initialPaths":["/Users/david/.atom/storage"]}]
  4. Closed atom with cmd + Q
  5. Opened application.json through finder with sublime text 3
  6. Confirmed application.json was still populated with [{"initialPaths":["/Users/david/.atom/storage"]}]
  7. Opened atom by clicking docked app icon

Atom opened with application.json and config.cson (and the .atom folder tree), plus another tab: an update notification - atom is now 1.12.9

Tested a few scenarios, seemed to be resolved. Then things got interesting.

I started testing a bit more, just to be more confident in my response, and it seemed to behave as before (discarding the session on open/close/open).

One scenario I tested included two new unsaved editor tabs with some content, no folder view. Cmd + Q, then reopened, one was missing, but one was still there (or some entirely unrelated one; I should have been more deliberate with the content, I just typed random characters). Now I get that single unsaved tab with that content whenever I open atom and application.json shows [{"initialPaths":[]}], but I can occasionally get it to persist a session with corresponding path in application.json.

Am I just not understanding how this persistence should work? I can’t identify any pattern, except it might be more apt to persist when the app loses focus before closing.


#9

It’s possible, but I’m not sure I can point to anything that you’re specifically doing wrong from your description of the steps. I know that if you make a change to the project paths and then immediately close Atom that the change will sometimes not get persisted. But it should still have the old persisted version.

What do you mean by “no new folder view”? If you mean that you opened or created an environment that had no project folders, then yes, the expected behavior is that the open editors are not persisted. This is because of the issue described here:

If you mean something else then help me understand :grinning:


#10

Thanks for all the help and patience.

Do you close the window before you close the application as described here?

Nope, just Cmd + Q. Sorry for missing this question earlier.

I know that if you make a change to the project paths and then immediately close Atom that the change will sometimes not get persisted. But it should still have the old persisted version.

It is likely that this is a contributing factor, as this could cause some randomness in my results (right?), depending on how fast I open/close, whether I switch focus, etc; things I’m generally not noting.

What do you mean by “no new folder view”? If you mean that you opened or created an environment that had no project folders, then yes, the expected behavior is that the open editors are not persisted.

I think that’s the pattern I’m seeing. I am also coming from sublime text 3 as are a lot of those posters, and expected unsaved buffers to persist from session to session, independent of having added or not added project folders. I might also have some expectations about “projects” left over from my eclipse and xcode days that is confusing the issue for me,

tldr; I think that last issue you referenced explains what I’m seeing. I’ll have to spend some more time with it and see if there is anything original I can contribute to the repo.