texstudio icon indicating copy to clipboard operation
texstudio copied to clipboard

use a temporary file to autosave

Open kendonB opened this issue 5 years ago • 14 comments

Environment

  • TeXstudio: 2.12.14
  • Qt: 5.8.0
  • OS: Windows 10
  • TeX distribution: texlive

Feature request

It would be great for TexStudio to autosave files using a set of temporary files that hold the current versions of the files currently in the editor. TexStudio would automatically open the files that are there upon start up. This way the user can feel assured that the file will still be there after a crash, the user doesn't have to worry about saving when closing if they do not want to (often the file is shared with collaborators).

This is how RStudio works (at least for "Projects").

kendonB avatar Jun 19 '19 23:06 kendonB

we have auto save, when saving, a new file is generated and renamed ,and you have the possibility to use SVN for version control management. I don't see any necessity to add something to that ...

sunderme avatar Jun 20 '19 10:06 sunderme

It might be a misunderstanding here. I think the OP requested a feature which will automatically save the open files to a temporary file every X seconds, so if TeXstudio or the computer crashes, the unsaved changes can be restored (like the "Document Recovery" in MS Word). Any behaviour that occurs when the user explicitly saves the file, or using SVN or any other VCS doesn't help in this case.

Document Recovery Screenshot

This seems to be a feature which would have helped quite a few users, as can be seen in this StackExchange question ;-)

luelista avatar Oct 27 '19 16:10 luelista

there is no auto recovery. txs uses "secure" save, i.e. saving a temporary file, remove old one and rename the new one.

sunderme avatar Apr 05 '20 11:04 sunderme

@sunderme But this only happens when saving manually or auto save is activated (which might not be desirable), right? This does not help in the case of a crash of the program or the PC, which is the problem of this issue as far as I understand it.

xuiqzy avatar Apr 07 '20 09:04 xuiqzy

I don't follow. Creating a temp file and renaming reduces the chance of losing data significantly. Depending on the time of crash you either have the original (no overwritten), temp and the final written file. Apart from that, txs supports subversion check in on write which generates a version history.

sunderme avatar Apr 11 '20 19:04 sunderme

AFAICS, the request is not about data loss during save actions, but rather about preventing loss of yet unsaved changes due to any crash.

When I‘m editing mydoc.tex TXS would periodically save unsaved changes to a backup file, e.g. ~mydoc.tex. When saving the original file or closing it in the editor, ~mydoc.tex gets deleted. I.e. the file is never present if I exit cleanly. It would only be there in case of a crash. We can then check on startup if there is such a file. If so, issue a message, „Found unsaved changes, do you want to use these?“ I think that‘s how MS Office handles this.

timhoffm avatar Apr 11 '20 21:04 timhoffm

@timhoffm Yeah, that is exactly what I meant. Many people don't need, want or can't use a subversion check in on save (with periodic save then I guess? Else it does not solve the problem), so a generic crash recovery of unsaved changes would be really useful.

Also see the linked StackExchange question from the other comment above and their answers with quite a few upvotes and comments, so this seems to be a problem for a lot of people unfortunately. (It doesn't mean TexStudio crashes but the Operating System or Hardware could be the cause)

xuiqzy avatar Apr 12 '20 11:04 xuiqzy

so, basically we want the regular autosave to use a different filename ?

sunderme avatar Apr 14 '20 06:04 sunderme

Yes. Plus:

  • delete the temporary file on a regular save
  • check on startup if such a temporary file exists (which indicates that the program finished unexpected) and notify the user
  • probably auto-save more often at least every minute.

Note: Saving to a different name is a bit more complicated than one may think, because the document changed logic and UI updates are folded into the save function, which needs to be untangled a bit so that the temporary save does not update the change state of the actual document.

timhoffm avatar Apr 14 '20 10:04 timhoffm

@sunderme could you or someone else reopen this issue? As far as I understand it, this would be a useful feature, but cannot really be achieved with the currently implemented features.

xuiqzy avatar Sep 07 '20 08:09 xuiqzy


TXS version: 3.0.1 OS: windows 10

I have not enabled the AutoSave option. I moved a section of file to untitled.tex. The OS hanged and I had to perform manual reboot.

Is there a way to recover the untitled.tex either from

  • TXS, or
  • System Error Memory Dump File?

Lesson Learnt: Enable Autosave

Baalkikhaal avatar Jun 15 '21 07:06 Baalkikhaal

there is no way to recover the file.

TXS version: 3.0.1

OS: windows 10

I have not enabled the AutoSave option. I moved a section of file to untitled.tex. The OS hanged and I had to perform manual reboot.

Is there a way to recover the untitled.tex either from

* TXS, or

* System Error Memory Dump File?

Lesson Learnt: Enable Autosave

sunderme avatar Jun 15 '21 15:06 sunderme

+1 for this enhancement. Recently lost a few paragraphs when my laptop battery died suddenly.

NitramC avatar May 06 '23 13:05 NitramC

I don't like to bump old issues, but this would also really help with Windows's tendency to automatically update when unattended. As of now the system just reboots and you loose everything since the last "wilful" save action (according to this, there is no reliable way anymore to even block restarts).

mirh avatar Dec 21 '23 16:12 mirh