Maybe the session should be saved before opening a project (at step 2 in the OP or step 4 above) so the right thing can be restored after?

The trouble with this session management code is that it gets called from many different places and on different occasions so the "before opening project" place is e.g. at

and then you'd have to add big fat comments regarding why you are placing the saving there and not in project opening itself. Also, this would lead to a double-save for sessions where you don't close all files before loading a project.

As I said, I think the whole session management should be rewritten but that's a major task.

Although on thinking about it, why wasn't the session saved at step 3 above?

Notice what this patch does for project opens:

if (have_session_docs())  // <-- the patch adds this check
 	configuration_save_default_session();

This is called in two cases:

  1. The currently buggy case - open project session -> open project session transition where the current code saves the empty session after closing the first project.
  2. The currently non-buggy case default session -> open project session where the default session really doesn't contain any file and you want to save the "no open file" state. This patch breaks it.

Note that (2) will break only for the case when both of these conditions are satisfied:

  1. save_config_on_file_change is disabled (which is not by default)
  2. Only when in step (3) from my previous post you close all of the files - if you keep at least one file open, it gets saved

Since I think this behavior is much less problematic than losing the whole session and it is rather hard to trigger, I think it's an acceptable workaround until someone decides to rewrite the session management code from scratch.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <geany/geany/pull/3898/c2183951710@github.com>