From 0b593eb7d0e6907b19cdbb605caf1becae351004 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 28 Dec 2025 21:22:46 +0100 Subject: fixed left-over recovery files * It was possible to provoke left-over recovery files even if the editor does *not* crash: 1. If you dirtified the buffer (state = TECO_BUFFER_DIRTY), it would be dumped to a recovery file (TECO_BUFFER_DIRTY_DUMPED). 2. If you dirtify the buffer again, the state will become TECO_BUFFER_DIRTY again, so it's up for dumping in the next cycle. 3. If you now save and exit (e.g. `:EX`) the recovery file is not deleted since the state is not TECO_BUFFER_DIRTY_DUMPED. * A buffer can have a recovery file both for TECO_BUFFER_DIRTY and TECO_BUFFER_DIRTY_DUMPED, so we must clean up afterwards in both states. * Of course, it may __not__ yet have a recovery file in the TECO_BUFFER_DIRTY state. The g_unlink() might therefore be superfluous on those files. Moreover, if you disable recovery files, SciTECO will now still try to unlink the recovery file. These operations could only be avoided by adding yet another state, e.g. TECO_BUFFER_DIRTY_OUTDATED_DUMP, so that after the first dump you will never switch back into TECO_BUFFER_DIRTY. --- src/ring.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ring.h') diff --git a/src/ring.h b/src/ring.h index 8b8beaa..4624983 100644 --- a/src/ring.h +++ b/src/ring.h @@ -26,8 +26,9 @@ #include "list.h" typedef enum { + /** buffer is freshly opened or saved */ TECO_BUFFER_CLEAN = 0, - /** buffer modified */ + /** buffer modified - if a recovery file already exists, it is outdated */ TECO_BUFFER_DIRTY, /** buffer modified and recovery file already written */ TECO_BUFFER_DIRTY_DUMPED -- cgit v1.2.3