Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make an option to always restore the last session #13947
Make an option to always restore the last session, no matter how Atom is invoked (#9643).
Description of the Change
TL;DR: none, see the issue #9643 for an extended discussion.
Why Should This Be In Core?
This is a standard behavior for most of modern multi-tab apps today, i.e. the ability to restore the last session after crash or normal exit, no matter how the app is invoked for the first time since the last session (i.e. with or without path parameters).
See the previous point.
None as this is an option turned off by default, so it won't affect anyone if not explicitly terned on by the user.
So far no issues were discovered.
script/test: 23 passing (2m), i.e. no errors when the option is turned off (the default behavior)
If you "Open with Atom" a single file what happens? If you run it from the command line like
What do you mean by hangs? Complete freeze, atom process has no activity in task manager? Or does it process something (e.g. high CPU usage, disk reads, etc.)?
In all cases, if you try again (Without killing the frozen process) it works.
Calling Atom directly (using Icon) works well.
Sorry. I don´t have Win7/8 to test.
The problem is actually with
In this case I'm not sure if it makes sense to include lodash (looks like it's not included otherwise) or to define own deepclone function as it was before the latest commit. @steelbrain, any suggestions?
Can anyone please explain the rationale behind
Also, I just checked and underscore-plus does offer a deep clone,
Haven't seen it due to its reverse-name. Sure now it's much simpler, just had to change the name. No dependency on lodash now.
I don't see how this is going to solve the problem in the issue linked.
The underlying problem there isn't that Atom doesn't restore your last project (it does) - it's that opening a random file effectively creates a new project that is now your last project.
How does this address that - I can't tell from the diff.
The original post said:
This is the actual behavior with the option set to 'yes', i.e. when Atom is started without arguments, it restores the previous session with all folders and tabs. When it's started with arguments, it doesn't restore the previous session. So the user then said:
This is the behavior with the option set to 'always', i.e. when Atom is started with arguments, it restores the previous session and adds the files (requested via arguments) to the restored session.
Then other users said:
What most users were reporting is that opening Atom with arguments was forgetting the previously opened folders and tabs, so the users had to re-add them manually again and again. What the 'always' option does is that the project folders and tabs are never lost, so no need to re-add them if you start Atom with arguments or use the context menu "Open with Atom" when Atom is not running.
If you just seen the code, I suggest you try to build Atom with this PR and compare the behavior with 'yes' and 'always'. You'll see that with 'always' Atom never forgets the previously added folders/tabs.
@jsolisu, if you mean that it creates 2 windows when you open a folder, it's by design. I.e. if you want to open a folder that would be added to the restored session in the same window, you should pass
If you open file(s), it(they) will be added to the same window where the previous session is restored. It's possible to make some changes to open a new folder always in the same window, but I guess it's not what others would expect.
Please let me know if my explanation is not clear.
We could create a new option that would indicate to always open a new folder in the same window, but I believe it would be better to start a new issue and a new PR for this.
Sorry took so long to get back to you, I wanted to understand the issues and try to better understand this fix. I think that the main issue was a combination of a few issues that have been resolved since.
Opening file from file explorer
Result: Atom opens the previous open project and opens the file on a new tab in the same Atom window.
Opening folder from file explorer
Result: Atom opens the previous open project(from step 1) and opens a new atom window with the folder you opened in step 4
Opening file from file explorer
Result: Atom opens a window with the project of the file open on step 4, the previous project doesn't open.
Opening folder from file explorer
Result: Atom opens a window with the project from step 4, the previous project isn't open.
On Ubuntu, I saw the same behavior as Windows.
Overall, I think this is a improvement and gives people the flexibility to open single files on their current session. The only weird behavior I saw was on Mac when you close all the atom windows but the Atom application is still running. Now that there's a
Bryant, thanks for this thorough review.
The issues and PRs you mentioned, if I understand them correctly, are actually for the behavior when the session is NOT restored, i.e. when the current option is set to NO. Aren't they a compliment to this PR?
What this PR is trying to solve is to implement a behavior typical in most multi-tab programs, like browsers, editors, etc.: when you configure the previous session to be restored, it is restored no matter how the program is started, i.e. alone or opening additional files. E.g. if Firefox is instructed to restore previous session, when we start it (say after a reboot) by clicking on a link in a Thunderbird mail, Firefox opens the previous session and creates a new tab for the requested link. The current behavior of Atom is to ignore a previous session if a link is clicked (i.e. a new file is opened), but it restores the previous session if it's started without opening anything in addition.
With respect to Mac, I'm not familiar with Atom on Mac, so I can't say much. From you description it looks like the main process is still running, and the X just makes the windows disappear, so when new windows are created, the initialization logic is not executed. One could say that this particular case doesn't strictly apply to this option as it says "on start", but if Atom is still running, you're actually not starting it.
In any case, if the users will ask to extend this feature to that particular case too, we could investigate the state in which Atom is after closing all windows on Mac and find a solution to restore the previous session for this case too. Does it sound reasonable?
yes, the issues that are fixed, make it possible to open old sessions, and not lose data while doing it. In that sense they are compliments to this PR, and yes the data loss issue occurs when you have a atom window without a project.
The Reopen project Feature: #13046, makes it possible to easily open recent projects, but I do agree this change is a improvement.
I think the current behavior on mac where Atom application is still open is the expected behavior in this case. I've compared this behavior with editors like sublime text behave the same way. If you close all your sessions and click on the dock to open Atom/Sublime, a empty window will open and not your previous session. So I think on mac, the moment you close all your windows, your current sessions is now empty so the expected behavior is to open the file project, or just the folder project if opened with
I'll follow up on this PR to see if someone can take a
@ungb totally correct. The big difference between something like Sublime and Atom there is that after you've opened a single file and closed the app, when you open the app again, you have the projects right there. With Atom we currently have to do the "Reopen project and re-collapse all projects on the sidebar one-by-one" dance, which isn't very fun