posit-dev / positron

Positron, a next-generation data science IDE
Other
2.51k stars 79 forks source link

R: Add more control for users to load and save .RData #964

Open petetronic opened 1 year ago

petetronic commented 1 year ago

A request was made to support the same options for .RData load/save that RStudio provides. That is, options to:

at the user level and at the workspace/folder/project level.

jennybc commented 1 year ago

Adding some color commentary:

We might hear about this situation soon-ish, because Positron currently can load a pre-existing .RData, lying around from previous work in a project outside of Positron. And the user can obviously modify their global workspace within Positron. But currently Positron won't save the new workspace state back to .RData, which is going to lead to a Groundhog Day experience (as in the movie) for anyone who hasn't adopted the "no .RData save/reload ever!" lifestyle yet.

Reflecting on the bullets above which describe RStudio behaviour, I do wonder: do we really need all 4 combinations?

                  Load .RData
                  at startup
                  ___________
                    no  yes
Save .RData | no  |  A    ?
on exit     | yes |  ?    B

I live in state A and I know many people live in state B, though I think it's a bad idea. But does anyone really live in the ? states? They seem very weird to me.

jmcphers commented 1 year ago

I do think it would make sense to have a single "persist workspace" off/on toggle.

I also wonder if this should really be an R language pack feature, or if it should be a Positron-level feature that is implemented by language packs. i.e. if your lifestyle is "save my objects when I close so I can keep working on them when I open", I can't think of a reason that should be scoped to a particular language.

AFAIK there is no moral equivalent in Python, but it is not too hard to simulate w/ pickle and/or shelve. Notably Spyder (which is kind of an RStudio clone for Python) has its own .spydata file format that appears to have been invented for the express purpose of creating a Python Save/Load Workspace experience.

jennybc commented 1 year ago

I realized the table above is too simple, because "Save .RData on exit?" can be yes, no, or ask.

                  Load .RData
                  at startup
                  ___________
                    no  yes
Save .RData | no  |  A    ?
on exit     | yes |  ?    B
            | ask |  ?    C

I maintain that the ? states are strange and think it's OK to not support them. The C state does not appeal to me, but this is actually R's default behaviour, so lots of people must live this way.

Recap of what we should support: