martinrotter/textosaurus

Restore previous session does not work with forced shutdown

travankor opened this issue · 5 comments

Brief description of the issue.

Textosaurus restores the previous session of all file tabs when textosaurus is closed gracefully. However, when a forced shutdown/restart occurs, textosaurus can not restore previous session.

How to reproduce the bug?

  1. Enable restore previous session in settings.
  2. Open several files.
  3. Instead of gracefully closing the window, restart the computer.
  4. Start textosaurus on the next reboot.

What is the expected result?

On the next launch, textosaurus will launch all saved and unsaved tabs.

What actually happened?

On the next launch, textosaurus loses the state of all tracked tabs and launchs with a new text file tab.

Other information (logs, see Wiki)

N/A

Yes, at this point list of currently opened documents as persistently saved when application exits. If PC gets restarted or application crashes, then session is not stored.

Perhaps I could store session not only when app gracefuly quits but also when one of these events occurrs:

  • new document is opened
  • some document is closed or saved
  • order of tabs is changed

Those bullet points sound like a nice idea to implement.

Something that I don't like in the current behavior is that a previously saved session can be replaced by a blank session (new text file). Maybe there is a way to store old sessions and let the user choose a specific session?

Maybe there is a way to store old sessions and let the user choose a specific session?

No, not yet.

I am thinking deeply about this. I mean, I can certainly implement this "auto-saving" of session on these events:

  • new document is opened
  • some document is closed or saved
  • order of tabs is changed

This is ok, but what if user has opened and MODIFIED some files. Now, auto-save of sessions runs -> file is modified, should it ask user if he wants to save it? No, it cannot, the "auto-saving" of session should be able to run without user interaction. It would disturb user if it asked him all the time about saving.

So my conclusion is, that "auto-saving" of session should not actually "save" modified files but only store list and order of opened files just to be sure that when textosaurus crashes, then list of opened files is maintained.

Of course that this feature would work nicer if it was paired with periodic "auto-save" feature which will really save even contents of modified files regularly.

What you think?

Yes, I think auto-saving the actual file should be separate from saving the session.

That said, if the application crashes and there are modified files, those modified files should be saved to the disk if possible.

This is ok, but what if user has opened and MODIFIED some files. Now, auto-save of sessions runs -> file is modified, should it ask user if he wants to save it? No, it cannot, the "auto-saving" of session should be able to run without user interaction. It would disturb user if it asked him all the time about saving.

Of course that this feature would work nicer if it was paired with periodic "auto-save" feature which will really save even contents of modified files regularly.

Yes, this sounds like a separate feature. Maybe make the auto-save timer configurable (every 30 seconds to 15 minutes all modified files get written to disk, or something like that).

So, autosaving the session should involve:

  • document is opened
  • document is closed
  • order of tabs is changed