OS: Windows 11 Geany Version: 1.38.0
https://user-images.githubusercontent.com/68846168/190093275-66dd14b0-2164-4...
What happens is that when you enable autosave the timer goes off and that calls `document_save()` which does a disk check, which finds the file is missing and pops a dialog to ask if you want to save the document to the same file (this is the normal behaviour of document saving, if the file isn't there its not clear that the user wants to save the document in the same place).
But because you have set the save timeout so short by the time you dismiss the dialog the timer has gone off again and calls `document_save()` which does a disk check, which finds the file is missing and pops a dialog to ask if you want to save the document to the same file ... etc etc etc
What happens is that when you enable autosave the timer goes off and that calls `document_save()` which does a disk check, which finds the file is missing and pops a dialog to ask if you want to save the document to the same file (this is the normal behaviour of document saving, if the file isn't there its not clear that the user wants to save the document in the same place).
But because you have set the save timeout so short by the time you dismiss the dialog the timer has gone off again and calls `document_save()` which does a disk check, which finds the file is missing and pops a dialog to ask if you want to save the document to the same file ... etc etc etc
Then I would like to request a new feature which is only autosave the file when the file is created/existing and won't autosave if the file is deleted or not existing.
Then I would like to request a new feature which is only autosave the file when the file is created/existing and won't autosave if the file is deleted or not existing.
Besides, most of the text editors are working like that, which is only autosave the existing files and won't pop up anything if the files are deleted or not created. So it would be more convenient if Geany could have this.
most of the text editors are working like that, won't pop up anything if the files are deleted or not created
Autosave is about safety, making sure the document is saved if something goes wrong with Geany, the system, or the file system. So, what this says is when the file is deleted, these other apps won't save, and won't tell the user that they are not doing so? How terribly safe ... not. Especially when the file has disappeared, so the document has no on-disk presence, great, just the time to stop saving and not tell anyone.
Clearly I don't think much of those apps approach :wink:
Saving a file is a surprisingly complex process with all the transformations at save, encoding, trailing space removal, multiple ways of actually writing the data to disk, etc. So its not surprising that the plugin uses the Geany `document_save()` rather than re-creating that functionality, but `document_save()` is intended for use in an interactive environment, it has several places where it has potential user interaction so its not really the best solution for automatic functionality.
It may be possible to refactor to separate the interactive parts from the actual saving process, but I am not sure without actual analysis that it can be done without creating or increasing race conditions (where something is tested in one place, eg the file exists, and is assumed later to be true, the further those are separated the greater the possibility of something changing externally, eg the file being deleted between test and save).
Anyway if somebody wants to propose something it can be considered.
For safety, there is already a function which is autosave when losing focus. Plus, as far as I know this is the only way to fix a bug which I just opened an issue just now but not sure if someone deleted my issue or it's GitHub problem. Anyway, another issue from save actions plugin that I opened is even I'm not deleting the files, it will also keep popping up the save file window after I just picked a new template file.
github-comments@lists.geany.org