Background, yesterday a thunderstorm caused a power failure when I had several 
modified buffers in Geany 2.0 (actually LSP but same thing) and Vscode.  After 
power came back on (8 hours later ... its was a _big_ storm) the system 
recovered fine, thanks ext4, Geany opened the right files thanks to regular 
saves of the session, but as expected at the last state I had saved them, so I 
have to figure out where I was up to and redo changes since that save.  Vscode 
on the other hand opened the buffers at pretty much the state at the power 
failure (might have lost a  few characters of the one I was editing at the 
time, but hard to tell, anyway not much) and of course marked them as modified 
again.  I didn't think to check if the undo/redo list was restored as well.

It seems to me that it might be possible to add this as an extra function in 
the save actions plugin and this issue is to record a reminder.  I have not 
examined things in detail, but I realised a couple of important things:

1. the buffer can be saved in UTF-8, and just restored directly to Scintilla, 
2. just some metadata needs to be saved as well to restore the document state 
and then the buffer can be saved under a hash or some other unique name, no 
problems with replicating the directory tree
3. no need for all the complex save and load that applies to the actual files.

Havn't examined if all the metadata can be restored by a plugin, but should 
only need minimal extra if not already possible.  I doubt a plugin can stop the 
session loading the saved file, but if it overwrites Scintilla after the file 
is loaded at least a undo will be recorded so the Scintilla deltas 
functionality could be used to show whats different.

An alternative is to save the undo list instead of the buffer and replay it 
from the last save (but I'm not sure if absolutely everything is put in the 
undo list).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/3733
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/issues/[email protected]>

Reply via email to