Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Unsaved buffer state isn't silently preserved when the Window has no project folder #13318

Open
iolsen opened this issue Nov 23, 2016 · 55 comments

Comments

@iolsen
Copy link
Contributor

iolsen commented Nov 23, 2016

Unsaved buffer state is preserved as part of the project system. When there is no project, it doesn't get saved. Prior to this fix this behavior could result in data loss. That's now fixed, but seamlessly preserving state as Atom does for projects would be more convenient and is the more elegant fix.

We would readily accept a well-tested PR providing this functionality.

See also #10474.

@rreinhardt
Copy link

I would like to suggest the addition of the label "data-loss" to this issue.

Having followed along from #10474, I think it's worth commenting that preserving the unsaved buffer state is important for non-project documents because of situations where Atom is closed without having the time/ability to offer up the save prompt to the user.

A couple cases that have resulted in data loss for me in the past:

  1. When the Computer loses power (laptop runs out of battery).

  2. When the Application/System freezes so that the process has to be killed.


I also think there is greater usability for the application to constantly be at a saved state than have the user make a decision(s) at the time of closing the application.

@hydrandt
Copy link

I currently use Atom 1.8.0 on debian unstable, and the session/buffer saving has been working fine for quite a while, even for two atom windows in two different KDE activities.
Then Firefox used Atom to open some file I downloaded and all the sessions (and unsaved buffers) are lost.
Where does Atom save the sessions and unsaved files content? Is there a way to get the sessions back?

@50Wliu
Copy link
Contributor

50Wliu commented Dec 18, 2016

Atom 1.13.0 features a new Reopen Project feature that you can use to return to your old projects. Otherwise you would have to reopen the folder/folders that you were editing.

@Curros
Copy link

Curros commented Jan 5, 2017

Wow I just expend 1h looking to all the mess around this "bug".
I'm using W10x64 - Atom 1.12, and i have the same issue.

@50Wliu if the file is not saved, you lost it. Even using Ctrl+Shift+T

@Curros
Copy link

Curros commented Jan 5, 2017

I just instal Atom 1.13 beta and works "fine"!
Using W10x64 - Atom 1.13

PD: If I open the tree-view I can see that desktop is linked, probably is using it as project.
PD2: If I open other project the oldest buffer (not saved file) is not showed, but if I open no project again (desktop) I have the old buffer.

@ctwise
Copy link

ctwise commented Jan 5, 2017

Nope, Atom 1.13 beta still isn't working. It requires you to save the buffers. Sublime doesn't. That makes it perfect for scratch pads, open a new tab and start typing and pasting. Close Sublime, open it back up and the untitled buffers are still there.

@50Wliu
Copy link
Contributor

50Wliu commented Jan 5, 2017

@Curros I think you misunderstand this Issue. When there is no project folder open, Atom is (currently) incapable of saving the editor's state. Before, it would throw it away, which led to data loss. Now, it asks to save those files, which is considerably better than before, but still not at where we would like it to be - a consistent saving experience with or without project folders.

@lePereT
Copy link

lePereT commented Jan 6, 2017

I think that Atom could certainly learn from Sublime's default behaviour here. There are times when I've reopened Sublime after some days and found work/musings that I'd not even remembered I'd lost. This makes it a perfect environment to work in. Atom, I've been burned twice on 1.12 already. The 1.13 beta behaviour is better, but still unpredictable and therefore poor.

What's the technical barrier to implementing this fix?

@ctwise
Copy link

ctwise commented Jan 6, 2017

I believe they made a technical decision that contents of tabs are tied to "projects". No project, no auto-saving of content. I'm guessing that this issue would require some re-architecting of that approach and they really don't want to do that.

@50Wliu
Copy link
Contributor

50Wliu commented Jan 6, 2017

Yeah, @ctwise is pretty close. We choose the state key by passing in the open project folders and computing a SHA1 of that. If there's no open project folders, then we don't compute a key and hence the state doesn't get saved.

That being said, I did just rediscover #11122. I'll try to get some 👀 on it.

@lePereT
Copy link

lePereT commented Jan 6, 2017

Would be great, cheers. Even VS Code has recently added this behaviour in the form of 'hot exit' I think. I found it pretty invaluable when working on a desktop in Ghana last week with rolling blackouts. Pretty extreme coding :D

@caesarsol
Copy link

caesarsol commented Feb 23, 2017

Hello, I'm coming from Sublime as well and expected this feature! Would be wonderful to have it back 😄

Could a strategy be to associate a common default project to all project-less tabs?

@bnlawrence
Copy link

bnlawrence commented Mar 1, 2017

So, I don't think the "fix for telling me to save" (this one?) even works. As far as I can tell (1.14.4 on Mac Yosemite) atom still just silently kills my data when I close the window, no prompt, just data loss. Like everyone else, I'm so disappointed. Atom seems like magic, with the potential to really improve my workflow, but it has this yawning fatal problem. Not everything is a project ... and when things are time critical, I'd rather be working slower and know I wont have to do things twice than working faster but losing stuff.

I can't risk this, so like many others, it's back to sublime.

@lePereT
Copy link

lePereT commented Mar 1, 2017 via email

@iolsen
Copy link
Contributor Author

iolsen commented Mar 2, 2017

So, I don't think the "fix for telling me to save" (this one?) even works. As far as I can tell (1.14.4 on Mac Yosemite) atom still just silently kills my data when I close the window, no prompt, just data loss.

This issue is about better "hot exit" functionality, which I agree would be nice. But data loss is obviously critical and we'd like to address it more urgently. @bnlawrence can you tell us how you got to this state? (e.g. how did you open Atom? Is it an empty environment or are there projects? How are you closing Atom?) The fix you linked is working for others.

@bnlawrence
Copy link

bnlawrence commented Mar 2, 2017

Hmm. Of course it's not repeatable today.
However, up to yesterday I had never had a project.
From memory, it was straight forward:

  • create md file
  • open from finder with atom
  • make change
  • close window using red dot
  • reopen file from finder
  • no change visible ...

But today, I have some projects, and even though I'm doing this in a different folder starting with no editors open, I'm assuming it's somehow associated with a pre-existing project.

Unfortunately I have to do my day job, I'll try and get back to experimenting with atom, and this issue, within 48 hours.

@iolsen
Copy link
Contributor Author

iolsen commented Mar 2, 2017

Thanks for trying. Please do let us know if you can reproduce it as we take this kind of bug seriously. Just to be clear, in the current release:

  • When there's a project, Atom should close and silently preserve all changes. Opening the project again will restore the state.
  • When there's no project, Atom should prompt to save any file changes before closing.

We would like to make the second case behave like the first at some point but it hasn't yet been prioritized.

@bnlawrence
Copy link

bnlawrence commented Mar 3, 2017

Experience playing with Atom

  1. Remove my existing .atom directory (to avoid mucking with things I care about)
  2. Start atom up from the icon in my task bar.
    • Task bar seems to know about the last things I have opened with atom. Interesting. I guess that's knowledge held in mac-land.
  3. Content creation followed by red dot window closure does prompt to save. Good.
  4. Save file.
    • Attempts to save in the last directory I used with atom. Where is that knowledge held? Macland again?
    • Saved Data in new file.
  5. Create more content.
    • Crash editor with red button
    • Start atom from icon.
    • Open last file save above.
    • New content has gone. Data Loss!
    • Add more content.
    • Crash editor.
    • Open last file.
    • New content is there. Why this time?
    • Remove all welcome gubbins.
    • Crash editor. Open file.
    • That new content is no longer there.
    • Add extra new content
    • Crash editor. Open file.
    • Back to neither "new" or "extra new" content.
  6. Start with another new file.
    • Sometimes crashes return no new content, and sometimes does. I can't quite make up my mind whether the presence or absence of the welcome gubbins is relevant. I can't quite make this reliably repeatable.

** then I put my old .atom directory back **

  1. Real problems finding my last project, but more interestingly, the last dummy file content is sitting inside a window when I open a file from that same directory ... so despite the fact that data appeared to be dead before, by restoring my old atom directory, and opening an old project, I can now find this data. Where is this stuff being saved?
    • And now, when I try and kill that particular tab (as opposed to the editor), it tells me the data hasn't been saved!

@Ben3eeE
Copy link
Contributor

Ben3eeE commented Mar 3, 2017

@bnlawrence To clarify:

  • When you say Crash do you always mean that you close with the red button? Or do you perform steps to cause Atom to crash? And see this dialog:
    image
  • When you open the file you have saved/contains unsaved changes do you have an empty Atom window? With no project folder added?

@ungb Can you please take a look at the above report. Can it be related to #13873?

@bnlawrence
Copy link

Sorry, I've been very poor with my choice of words. "Crash editor" above means "close by terminating window, as opposed to via a menu choice".

@ungb
Copy link
Contributor

ungb commented Mar 3, 2017

Hey @bnlawrence,

It could be related to issue #13873, depending on what steps you took for the steps where you Open last file or Open file. If you open the file from the context menu when you open where atom doesn't have a project open already, then you are seeing issue #13873.

When you just close Atom via the red button on mac, Atom is still open if you are on mac. This is a feature on mac that isn't available on other OS.
In this case, if you completely exit out of atom cmd-q when atom is open, it will completely exit and when you open atom again it should restore your previous project (should do it by default config). If you just click Atom from the dock, it will open a blank window if atom is not completely closed.

For now, if you open the file from terminal it should work via atom <filename>

@aaranmcguire
Copy link

Does anyone have any update to when this will be looked into? I tried investigating today, but it's way above my head. It seems most of the logic is in the project.coffee file, and I assume that's why it only works with projects. (at least this is my assumption).

I really want to move to Atom, but this is the one thing I just can't live without.

@kbsantamaria
Copy link

Hi there! I'm new to Git and to the Atom project, so please be patient with me! I come from Windows and Notepad++, so this particular issue really stood out to me from the first time I used it.

I can reproduce this issue (maybe two issues?) in Atom 1.16.0 on MacOS Sierra. I have documents I've opened in Atom (originally created in Atom too) that are saved in ~/Documents or its subdirectories. When I open an existing document, make edits, and close with the red button, it never prompts me to save and changes are not saved automatically. When I instead create a new document on an untitled tab, I am prompted to save.

Additionally, the only way that I seem to be able to get the state of the window to save (ie, all of the tabs I had open the last time I was working are still open the next time I start Atom), is to save all work in each tab, then shut down my computer without closing the window or quitting the application. If I do this (even if I do not choose the option to re-open windows on startup), my state is saved.

I hope this helps someone! Please let me know if I can help with a solution, but I am an absolute beginner here.

@vsethi13
Copy link

@aism I feel your frustration. This was the exact reason why I moved back to sublime. Well, this and how Atom used to compete with Chrome in "who'll eat the most RAM on this computer" contest.

@mattantaliss
Copy link

On multiple occasions in the last few weeks, I have had Atom crash on me and I've lost all unsaved changes (tabs with unsaved changes are not restored). I'm running version 1.29.0. Have I missed a setting somewhere? Why is this not automatically handled? Notepad++ has had no problem doing this for at least the last few years. Would it be best to ditch Atom and go back to using Notepad++?

@jbjonesjr
Copy link

Thanks for this issue, I just got hit by this bug last week, and this was helpful to understand the scope of the issue. :( I get the reality of it, but was surprised still this was an issue.

The use case that got me to here was opening up a clean ATOM window to do some scratch work while working on another project. I wanted a clean workspace and panes, so New Window with a bunch of untitled tabs was my solution. Is there an easier way to stash a workspace that I should have potentially used.

Regardless, at some point my computer got unhappy with me, a reboot happened. I guess I always assumed there was some sort of default project (even hiding in .atom somehow) that this new window opened with, but alas, there was not, and my files were 🗑 .

Atom is so good at reopening old projects and files (and project state), it was surprising to find this gap. At least I know this now!

@iliakan
Copy link

iliakan commented Oct 28, 2018

Yeah, so bad it has inconsistent behavior here. Sometimes saves, sometimes not. Lost quite a bit of unfinished data because of that.

@Ashkaan
Copy link

Ashkaan commented Dec 5, 2018

@iolsen, are you guys still planning to add this feature any time soon?

I'm on MacOS and my options for a useful (to me) text editor are slim. Right now, Sublime is the only one I'm aware of that has this functionality. I've tried Brackets and Atom. If Notepad++ were (easily) available on MacOS, I'd go there.

@everyoneelse, are there any text editors that I should try that can do this just as Notepad++ and Sublime can?

@titoesteves

This comment has been minimized.

@iolsen
Copy link
Contributor Author

iolsen commented Dec 5, 2018

are you guys still planning to add this feature any time soon?

I'm not working on Atom any more, day to day. @asheren might be able to shed some light.

/cc @lee-dohm

@Ashkaan

This comment has been minimized.

@aronj

This comment has been minimized.

@soleares
Copy link

soleares commented Apr 6, 2019

@Ashkaan Most editors I've used on the Mac support this. BBEdit also does.

@mjarmijo
Copy link

Just lost some data from my laptop restarting over night. Would really like this feature!

@thargenediad
Copy link

Please add this feature! It's the sole reason Atom isn't my main text editor.

@CommanderPirx
Copy link

I can't believe it's been literal years since the lack of this feature has been highlighted for the first time and countless time people chimed in in the meantime about it, and yet nothing has been done about it. It's most basic and fundamental feature any worthwhile text editor should have. I just bounced off of Atom HARD because of it.

Oh well, I guess back to looking for an alternative editor...

@bean-drew
Copy link

bean-drew commented Jan 6, 2021

Looking for a free lightweight text editor for Mac (ie. Notepad++, but for Mac) and was recommended Atom. Figured out how to disable the project pane (via disabling a package), only to find (here, now) that the failure of session-save was because I wasn't opening my documents as part of a project ... Why does Atom need me working in projects - That does not align with my workflow. It also seems a bizarre omission, given wide adoption of this mode across other editors. However, across this thread and the linked "Unsaved buffers" thread it seems that this has been a long-identified issue that isn't changing. So per comments I've seen here I guess it's off to try Sublime [edit: not free]. Otherwise Atom looked nice, so, feature request?

@corsel
Copy link

corsel commented Feb 25, 2021

Wow, I wasn't expecting to see so much heat around this for literally years when I decided to give atom a try and shortly after started looking up google how to keep the unsaved session. I guess I'm also switching back to notepad++.

@JoshCheek
Copy link

This hits me very frequently (probably several times a month for the last several months, though there were times it happened multiple times per day) and it's the primary reason I'm looking at other editors. I've lost important meeting notes, todo lists, code snippets I was composing from REPL sessions, etc.

Perhaps it should be noted that I am almost always working on unsaved files. I dev in vim, and take notes / paste things I want to get out of the clipboard / experiment in Atom. So the idea of a project root or a file path is foreign to my mental model when using Atom, I am 99% of the time thinking about operations on an in-memory buffer. And it's just brutal to lose 10 buffers with important notes for the second or third time in a week.

I'd super appreciate a priority elevation for this issue.

While I came here to express this frustration, I've generally been >90% happy with Atom for 6 or 7 years now, so want to make sure to say ty times a million to the maintainers. 🙏❤️

@Philipp91
Copy link

I only need a text editor for single files, as I have other (language-specific) IDEs for programming. This means that I can use a workaround for this issue in Atom: Menu "File -> Add Project Folder" and specify sth like ~/.atom/default-project. (Optional: Hide the unhelpful "Project" pane on the left.) Now any open files and any newly opened files seem to be assigned to that default project and hence they get saved/restored as I expect. Or at least I haven't found a corner case where this workaround breaks so far. E.g. things like atom somefile.txt on the shell work fine.

@tom-newhall
Copy link

Hi, I'm something of a Newb with Atom.

I just want to confirm my understanding of the above issue---as of version 1.58.0 (using on 8/18/21)---there is no way to recover unsaved data from a previous session, even if autosave and autosave-onchange were enabled in the previous session.

Is that correct?

Thank you.

@bobemoe
Copy link

bobemoe commented Aug 18, 2021

@tom-newhall there is sort of a way, see the workaround mentioned in the post above yours. i.e always have an open project.

@tom-newhall
Copy link

tom-newhall commented Aug 18, 2021

@bobemoe Thank you for that; that workaround appears to work, for now at least. (I added my dropbox root as my ("default") 'project folder'; opened a new file in Atom; added some content; did not save it; restarted the computer. The file and content was there when I restarted atom)

Now that I've "Added" a "project folder" (added to what, I wonder?) should that stay as my "default" project folder on this machine, or do I need to re-"add" this folder every time I restart Atom from scratch? Is there a way I can check what "project folders" have been "added" to Atom?

Thanks again for the help

@JoshCheek
Copy link

JoshCheek commented Sep 17, 2021

This hits me very frequently (probably several times a month for the last several months, though there were times it happened multiple times per day) and it's the primary reason I'm looking at other editors. I've lost important meeting notes, todo lists, code snippets I was composing from REPL sessions, etc.

Perhaps it should be noted that I am almost always working on unsaved files. I dev in vim, and take notes / paste things I want to get out of the clipboard / experiment in Atom. So the idea of a project root or a file path is foreign to my mental model when using Atom, I am 99% of the time thinking about operations on an in-memory buffer. And it's just brutal to lose 10 buffers with important notes for the second or third time in a week.

I'd super appreciate a priority elevation for this issue.

While I came here to express this frustration, I've generally been >90% happy with Atom for 6 or 7 years now, so want to make sure to say ty times a million to the maintainers. 🙏❤️

sigh this is so absolutely tortureously brutal. Also, it's a regression, because this did not used to happen. I can't tell whether I'm lazy or a masochist for continuing to use Atom. It would be deeply appreciated if someone on the Atom team would at least acknowledge that this is a serious this issue. Literally every time my laptop runs out of power, I lose every single open buffer. Usually this is ten to twenty buffers. I put off restarting my computer because I don't want to lose what's in my buffers, but then I'm distracted and run out of battery and lose them anyway 😞

@icecream17
Copy link
Contributor

Added to todo list. But I have a lot of things going on in my personal life. Since there's not many contributors,

Could this be a workaround? #9968 (comment)

Helpful for future me: #10474 (comment) > #9968 (comment)

Does anyone know where the code dealing with saving buffers is?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests