Autosaves are created for unmodified files and not removed on close with split Editor panes
See original GitHub issueProblem Description
I can confirm that with the latest master
, I’m still getting the Recover from autosave
for files that were either saved or never unmodified when I closed Spyder (via the normal close button), with a clean autosave
directory and not other Spyders open before or currently. All the files I have open have autosaves created 1 minute after startup even if I’ve never touched Spyder, and they don’t get removed when I close Spyder again. This happens consistently, every time with every file I either have open on startup or open subsequently, regardless of whether I view, modify, etc. it.
I finally reproduced it starting from a clean --safe-mode
Spyder instance by opening a two-pane layout (“horizontal split”) and a few files and waiting 1 minute; it seems to be the two pane layout that triggers it, as it does not happen with only one pane open. I’ve tested enabling/disabling code style, docstring style analysis, projects, and more, and none of them have an effect on whether it happens or not, just the two pane layout.
I also thought they should be removed by spyder-ide/spyder#8733 anyway, but apparently that handles it by merely removing the autosave when the “Don’t save” button on the “Unsaved changes” dialog when closing the file is clicked, rather than when the file is actually closed (e.g. by the user, closing Spyder, switching projects, etc), and thus was not robust against any bugs (like that one) that might result in an autosave file being created for a reason other than an actual modification.
What steps reproduce the problem?
- Open a clean copy of Spyder
master
- Select “Split panes horizontally”
- Open a file
- Wait 60 seconds
Versions
- Spyder version:
master
as of post time (c90e2aea
) - Python version: 3.7.2
- Qt version: 5.9.7
- PyQt version: 5.9.2
- Operating System name/version: Windows 8.1 x64
Dependencies
pygments >=2.0 : 2.3.1 (OK)
qdarkstyle >=2.6.4: 2.6.5 (OK)
sphinx >=0.6.6 : 1.8.4 (OK)
pyls >=0.19.0 : 0.21.5 (OK)
nbconvert >=4.0 : 5.4.0 (OK)
pandas >=0.13.1 : 0.24.2 (OK)
numpy >=1.7 : 1.15.4 (OK)
sympy >=0.7.3 : 1.3 (OK)
cython >=0.21 : 0.29.4 (OK)
qtconsole >=4.2.0 : 4.4.3 (OK)
IPython >=4.0 : 7.2.0 (OK)
matplotlib >=2.0.0: 3.0.2 (OK)
pylint >=0.25 : 2.2.2 (OK)
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (14 by maintainers)
Top GitHub Comments
One bug is that when cloning an editor (e.g. because it appears in multiple panes),
.set_as_clone()
calls.setDocument()
here. This emits thetextChanged
signal which eventually leads to an autosave.Another issue is that the autosave name mapping is stored on the
EditorStack
level and thus not synchronized between the different panes.I have some ideas on how to fix this; I need to try out some things but I expect to have a PR ready this week.
Fantastic @jitseniesen ! Looks like the former issue is the ultimate culprit, while the latter made the problem more difficult to detect and fix in PR #9327 (otherwise it would have been basically a one-line fix).