Repository navigation
add option to choose whether atom rememebers your last windows and project folders - #9042
jordanbtucker wants to merge 3 commits into
Conversation
|
👎 on loading config twice. Is there a way you could achieve the same goal without this? We have to be tediously strict about counting milliseconds on window load. |
|
Also, what's your use case here? I'm personally not convinced this is a common enough need to warrant another checkbox in core settings. cc @atom/feedback |
Ditto. My window load time is long enough as it is 😉. As for use case, a lot of people have been asking for this in #6605. |
|
@jordanbtucker wouldn't it be enough just to save an empty state when closing atom and the setting is switched on. So you won't need to change to opening part at all. |
|
@thedaniel @50Wliu I totally agree with you on the loading config issue, but I haven't come up with a better solution, and config option is what 99% of the users wanted in their comments. I'm okay with removing the checkbox and making it config file only. I'm against having a command that disables saving on exit that you have to call every time. This should be a set-and-forget setting. Honestly, I feel this is on par with the "open empty editor" config setting. Seems odd to give that a checkbox, but not this one. Please leave any suggestions to improve this. I'll be so glad when this is fixed. |
I meant in your example you are returning out of the save function when your new setting is switched on and you have the same for the opening function. If you just change the saving part to save [] if your setting is switched on you don't need to do any changes on the loading part (less code to test, less side-effects). saveState/loadState do their work normally but you end up with a clean session every time. |
|
@m1ga I hadn't responded to your comment yet. With my method, you can modify the config file with the editor closed and it will honor your setting when it starts. If we go with your method, the option should be changed to "Save Your Previously Opened Windows" or something like that. Or maybe I'm just nitpicking. I'm not opposed to your method, but I just want everyone to be aware before we decide which way to go. One thing that needs to be said is that your method would eliminate the extra load time if I move all of the config logic into the saveState function. |
|
I am personally fine with it not being a checkbox. However, there should be some way that the user can find out about the option if they want to. Perhaps the main settings page links to a 'Configuration Reference' saying it contains additional options not displayed here? |
|
I removed the checkbox and it now only loads the config file when saving. I'm not sure the best way to use a config option that doesn't have a UI. Do I set the default in the code like I did on line 438? What other examples are there of settings that do not have a UI? |
There was a problem hiding this comment.
Nice work adding this integration test. The assertion doesn't seem right to me though; this is saying that there should be two Atom windows, each with no project paths. If we've chosen to not restore the session though, shouldn't there just be one Atom window with no project paths?
|
@jordanbtucker Thanks for diving in and taking a look at this. I'm 👍 on this change; a number of people have asked for it. I agree w/ @thedaniel that we don't need to add UI for it yet. I left some small pieces of feedback above. |
|
Good catch on the integration test. I can't actually get integration tests to work on my Ubuntu box, but hopefully the test is correct now. |
There was a problem hiding this comment.
Currently, I believe this will throw an exception when the user's config is invalid, because it will try to reference atom.notifications, which won't be defined in the browser process. If we're going to use the Config class here, I think we'll need to remove its dependency on the NotificationManager.
That code is also going to change a little bit when #8968 lands. Maybe instead of creating the notification inside of Config, we should add a method ::onDidFailToLoad(callback), and we can use that method in the renderer process to set up a callback that creates the notification.
|
+1 Bump! I'd really like to have Atom open clean every time and stop saving my session when I close it |
|
@jordanbtucker Are you still interested in doing this? It has actually become a little bit easier since we last talked, because of #9990. We are now using the |
|
Sure! I'll take a look at #9990 and start working on this again. Thanks. |
|
@jordanbtucker Yay! You rock! And thanks for the quick reply and review @maxbrunsfeld |
|
@maxbrunsfeld I looked through #9990, and the relevant code looks almost identical to what I've already written. Sorry if I'm missing something, but what do I still need to change to get this merged? |
|
@jordanbtucker We just need to avoid loading the config twice in the browser process. Currently, it's loaded inside of |
|
Excited for this! Personally, I want a clean slate every time Iaunch Atom. |
|
+1 Chomping at the bit for this change....needing to always close a mass of files on every startup is super not fun. |
|
You can shim this in atom right now with project-plus and the following line in atom.commands.dispatch(atom.views.getView(atom.workspace), 'project-plus:close') |
|
@maxbrunsfeld I made some changes that I think satisfy your requirements. Please take a look and let me know. Thanks. |
|
@jordanbtucker Max is on parental leave currently. I've added this to the queue to review but I don't have an ETA on when someone will be able to get to it. |
|
Thanks for the patience and the hard work on this, @jordanbtucker. ✨ I have started reviewing this and I think right now we may not be handling the scenario where the So, what do you think about moving that configPath = path.join(atomHome, 'config.cson')
config = CSON.readFileSync(configPath)
config['*'].core = {restorePreviousWindowsOnStart: false}
CSON.writeFileSync(configPath, config)What do you think? /cc: @atom/core |
|
I don't know much about the technicalities of this, but based on your comments, why does this have to be so difficult? Why save the previously opened windows at all unless explicitly told to do so? From the people I have talked to, none of them want the windows saved when they fully close the editor. Frankly, it's a pain in the butt that it does that currently. |
|
@jacobgraf This was a highly requested feature by the community: #1603 FWIW, Sublime also remembers its open windows and files by default, so this is actually expected behavior for those coming from Sublime, and is also consistent with the defaults of native document-based OS X apps. Once this PR lands then you'll be able to disable this. |
|
@as-cii Thanks for the feedback. You make a good point. I've pushed the changes you suggested. |
|
One thing I want to make clear to everyone (in case there is any confusion). This only applies to opening Atom without a path argument. If your config file looks like this: '*'
core:
restorePreviousWindowsOnStart: falseThen the following command will not open the previous session: $ atom # will not restore previous sessionHowever, the following commands will restore the previous session for that directory. # this will restore the state for this directory (if it was
# recently opened) regardless of restorePreviousWindowsOnStart
$ atom /home/me/project
# this will restore the state for the parent directory (if it was recently
# opened) of this file regardless of restorePreviousWindowsOnStart
$ atom /home/me/project/package.json |
| configPath = path.join(atomHome, 'config.cson') | ||
| config = CSON.readFileSync(configPath) | ||
| config['*'].core = {restorePreviousWindowsOnStart: false} | ||
| CSON.writeFileSync(configPath, config) |
There was a problem hiding this comment.
What do you think about moving this section before this LOC? This way we make sure that the setting works independently of when we change the configuration.
|
Just left one comment, I think we can |
A new Core Setting: Restore Previous Windows On Start
Enabled by default, so it's backward compatible.
Fixes #6605