[Github-comments] [geany/geany] Add reload all keybinding (#2859)

elextr notifications at xxxxx
Tue Aug 10 00:48:43 UTC 2021


@elextr commented on this pull request.



> @@ -335,6 +335,21 @@ void on_toolbutton_reload_clicked(GtkAction *action, gpointer user_data)
 	document_reload_prompt(doc, NULL);
 }
 
+/* reload all files */
+void on_toolbutton_reload_all_clicked(GtkAction *action, gpointer user_data)
+{
+	guint i;
+	gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
+	
+	foreach_document(i)
+	{
+		if (! (documents[i]->file_name == NULL))

> The dialog is necessary only if:

> any of the open documents has unsaved changes
> keep_edit_history_on_reload is off

Sure, a single dialog is fine, but as I noted above, in the situation that a buffer has been changed and saved and then the file on disk is changed, for example by git checkout,  is another case where you are about to lose your changes as the buffer is reloaded with the changed disk file.  So just testing for unsaved is not sufficient and that is why the tests in `document_reload_prompt()` also check for any undo-able changes as an indication that the buffer was edited and saved.

I guess that, at least in the git checkout use-case the user had to explicitly specify files to change, since git won't overwrite modified files when just specifying a branch or tag or commit so you don't lose them.  IIUC thats the use-case that @Davidy22 has, so I can see why he is grumpy that he gets a prompt for each of the files that he has explicitly told git to change.

But other file-changing use-cases may not be so user friendly and we open those users (who are not having any say in this discussion) up to the risk of data loss if we only test for unsaved changes when keep_edit_history_on_reload is off.  

I suggest that if there is to be only one prompt then testing all files for unsaved changes or undo/redo data should be ok, especially when it only happens if keep_edit_history_on_reload is off.  

So to summarise to ensure we are all on the same page, I am suggesting that if keep_edit_history_on_reload is off then a loop tests buffers for unsaved changes and undo/redo data and as soon as one is found exit the loop and make one prompt.  If the result is "reload" or keep_edit_history_on_reload was found to be on then simply loop and reload all files with no further prompt.

-- 
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/2859#discussion_r685613205
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20210809/d7ebbd0a/attachment.htm>


More information about the Github-comments mailing list