Repository navigation
Add auto-save options and finer control of backup - #5565
Conversation
How difficult would it be to ensure that Source on Save sources the file, but only for user-initiated saves and not auto-saves? |
Not too hard, but I don't think that Source on Save is philosophically compatible with autosave. Either autosave option puts you in a world where manual saves aren't a thing, and you can just use the Source command if you want to source. |
| prefs_.surroundSelection().setGlobalValue(delimiterSurroundWidget_.getValue()); | ||
| prefs_.executionBehavior().setGlobalValue(executionBehavior_.getValue()); | ||
| prefs_.autoSaveOnIdle().setGlobalValue(autoSaveOnIdle_.getValue()); | ||
| prefs_.autoSaveIdleMs().setGlobalValue(Integer.parseInt(autoSaveIdleMs_.getValue())); |
There was a problem hiding this comment.
Do you think it's worth using StringUtil.parseInt(<...>, 1000) here, just to avoid a potential exception from a parse failure? (It looks like invalid options are handled in the dialog directly but being paranoid doesn't hurt here)
| getPath() != null && | ||
| !docDisplay_.hasActiveCollabSession()) | ||
| { | ||
| save(); |
There was a problem hiding this comment.
Can we do anything to swallow exceptions here, if the save were to fail for some reason?
There was a problem hiding this comment.
(I'm thinking of the occasional error modal that users sometimes see when trying to work with files in e.g. Dropbox, OneDrive, and so on)
|
|
||
| // Save (and keep track of when we initiated it) | ||
| saving_ = System.currentTimeMillis(); | ||
| save(() -> |
There was a problem hiding this comment.
Similar here: can we handle exceptions during save?
| { | ||
| // Cancel any existing autosave timer | ||
| if (autoSaveTimer_.isRunning()) | ||
| autoSaveTimer_.cancel(); |
There was a problem hiding this comment.
FWIW you can call cancel() directly (it will be a no-op if the timer is not running)
There was a problem hiding this comment.
That'll save a couple of lines. :-)
|
Hello, could you please tell me what has changed in the rstudio? I can no longer backup my project on dropbox as it sees conflict even after the selective sync. Everything disappears after the opening each rstudio project for the third time |
|
Where are the new auto-save options located? I don't see them under Global or Project options in RStudio 1.2.5019 on Windows 10. Thank you for tackling this incredibly aggravating issue! I know it's a niche problem, but it has been annoying me for years. |
|
They are part of the development version of RStudio and haven't yet made it to the stable builds. If you'd like to try the dailies, we'd appreciate any feedback you have! https://dailies.rstudio.com/ |
|
Thanks for the link to the dailies. I've been using version 1.3.618 on and off for a few days, and with the "Automatically save when editor loses focus" option checked, and the "When editor is idle" option set to "Do nothing," I'm no longer getting the error message. FYI, in my case, this had been happening with a project living on a shared network drive. My only suggestion is that it might help to clarify the difference between backing up unsaved changes vs save and write changes. |
|
Can someone explain the path to find these auto-save options, I am not finding it in Rstudio menu |
I'm on windows, running RStudio 1.3.938 and found them in: |
This change adds some new options that control automatic saving and backup behavior.
Autosave
It is now possible to have RStudio save files for you automatically, instead of requiring a manual "save" gesture. You can have this done either after a short period of inactivity (idle), when focus leaves the editor, or, if you're really paranoid, both.
Autosave doesn't pair well with Source on Save since sourcing an R file can be expensive and shouldn't be implicit. For this reason, turning on any autosave option turns off Source on Save.
Backup unsaved changes
Backing up unsaved changes (which confusingly is also sometimes referred to as "autosave") is now configurable; you can adjust the idle interval or turn it off entirely. This should be helpful primarily for users on systems like Dropbox or Google Drive who have problems with RStudio's frequent file writes.
In order to avoid tripping over its own feet, RStudio doesn't allow two different idle timers for backing up unsaved changes and auto-saving; you can only get one idle behavior.
All of this new behavior is opt-in; left at the default values, RStudio will behave exactly as it did in past releases.
Closes #3837.
Closes #4511.
Closes #5263.