[Github-comments] [geany/geany] Fix 'changed' flag being altered when all documents are closing. (#1857)
chrontec
notifications at xxxxx
Mon May 14 03:24:25 UTC 2018
Maybe a use case will make it easier to explain? I was working with a plugin to save the current fold state when a document is being closed. This works just fine, except in a specific case - if the document is being closed and there are unsaved changes, i.e. the 'changed' flag in the document reference is TRUE. In this case I would want to ignore saving the fold state since the next time it is opened all the fold points will likely be wrong. A simple approach to address this would be to not save the fold state on document close if this flag is TRUE. This works when a document is closed when I close a tab in the UI - I see the changed flag is set to TRUE and can therefore ignore trying to save the fold state.
There is a specific case where Geany closes a document and the 'changed' state is *always* FALSE, even if the document has changes that the user discarded. When Geany calls the 'document_close_all' function, like when Geany is being closed, internally that function calls 'document_account_for_saved' which in turn will always set the 'changed' flag to FALSE before closing a document, so when the document is closed I can never tell if there are unsaved changes or not. This fix changes Geany to close all documents, but to leave the 'changed' flag untouched so a plugin can see whether any unsaved changes are being discarded when a document is being closed.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1857#issuecomment-388686531
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20180513/67b3754a/attachment.html>
More information about the Github-comments
mailing list