Every time I open a particular project in RStudio, it opens the same 3 unsaved files. But not just one copy of each file; it opens many copies of the same files. Over time, the number of copies that it opens continues to grow. Every time I open the project, I start by closing ALL the unsaved files. I don't want them. I didn't save them, after all. But when I reopen the project, they open again. I've tried deleting the project (both the .Rproj file and the .Rproj.user directory) and creating a new one, but the issue persists. It's really rather annoying, as it's a project that I work on frequently. How do I get rid of the unsaved files??
Somehow that seems to have made things worse. I updated RStudio to version 2024.04.02 and unselected "Restore previously open source documents at startup" from the general settings (all the project Workspace settings are set to default). I then closed all the open source documents, closed RStudio, waited a few seconds and opened RStudio. The first time I opened RStudio it opened half a dozen source files from the project. I don't know how it selected which ones to open. So I closed them, closed RStudio, and reopened. This time it opened fewer source documents, but it included a couple copies of the unsaved source documents. So I repeated. On the third time it opened only the unsaved documents, and it opened 76 total unsaved files (all copies of the same 3 files). I tried closing and re-opening a few more times and changing projects. In all projects RStudio still opens files, and in the project in question it opened 60-80 (total) copies of the same 3 unsaved files each time.
I'll try renaming the %localappdata%\RStudio directory next. For now, I think I solved the problem by deleting the .Rproj file and the .Rproj.user directory for the problematic project. (Yes, I tried that before, but maybe the combination of updating RStudio and deleting the project worked??) Before doing so, changing projects within RStudio would re-open source documents in each of the projects, even though the general settings told it not to. After deleting (and recreating) this one project, now no projects open source documents when I switch to them or when I open RStudio. If things start re-opening in the future, I'll try resetting the %localappdata%\RStudio directory.