SUMMARY I mistakenly clicked on the "close other" context menu item on a big project session which closed (many) other open documents, and since there is no "undo" button for the action, I closed the window and tried to relaunch the session again, only to find out it had been automatically saved after the "close other" action. STEPS TO REPRODUCE 1. [Back up the session you wish to test this on] 2. Open session with multiple open files 3. Switch to "tree mode" in "view mode" context menu 4. Right click on a file in a directory with multiple files, and click on "close other" 5. Close the window, without saving the session 6. Relaunch kate with the session OBSERVED RESULT Session has automatically been overwritten with the results of the "Close other" action EXPECTED RESULT No auto-overwriting of session. SOFTWARE/OS VERSIONS Linux/KDE Plasma: Fedora Core 30, KDE Frameworks 5.64.0 Qt 5.12.5 (built against 5.12.5) Kate: Version 18.12.2, and git master as of 2020 January 11 ADDITIONAL INFORMATION If we are auto-saving in case of a crash, we should auto-save to a special "autosave" session, not the current session, which otherwise requires manual saving (the expected behavior). If a dev that knows where the fix could go but has no time to fix it themselves wants to point me in the right direction to fixing this, I could try to see if I can do it myself.
Further testing reveals that the problem isn't with the "close other" feature, but rather that closing the session triggers its automatic save ( KateSessionManager::saveActiveSession -> KateSessionManager::saveSessionTo ), which is a departure from how it used to handle the situation. kate should not overwrite the current session when closing the application, but instead, if an autosave is desired (optimally, this should be a user-selectable option) it should save to a designated /different/ file (say, "autobak.katesession") or to a "backup" copy of the session (ie, if using "my session", it should create a "my session-autobak" session or something like that). I'm going to see if I can whip up a quick patch, if at least for those who want a parting point to work on this.
Created attachment 125049 [details] patch to prevent autosave on close The following patch prevents autosave on close. I don't know if it breaks anything else, but this is what I will personally be using to solve the problem for me until a config option is created for this. (I don't think I will be able to devote time to that at any time soon, unfortunately). Hope this is useful as-is to somebody else too.
Created attachment 125050 [details] prevent autosave when user clicks on "Quit" option in file menu Second patch. This one also prevents the autosave when the user clicks on the "Quit" option in the file menu.
Is it that with these patches one always has to save manually?
(In reply to Dominik Haumann from comment #4) > Is it that with these patches one always has to save manually? Yes. Which is how it used to be, at least for me. Optimally a configuration option to select autosave should be coded for those who want it to work that way. For me, I make mistakes often, and I would rather not have those mistakes irretrievably autosaved. It would also be quite good to have an "undo close file" but that's probably an even bigger undertaking than the config option. Even a prompt before closing that asks if you want to save the session before closing would be good (with it's own config option too, for those who don't want to have to click one more thing before closing). The patches at least help pinpoint the two places where a dev can start looking into the solution for this.
Patch submitted to: https://invent.kde.org/kde/kate/issues/8
Hmm, I am not sure if that behavior change is wanted. Was there ever a time when the session wasn't saved automatically? If we add such a change, that should be a configure option like "auto save session", that is default "on" For the patch submission: It is better to create a merge request at invent.kde.org, having there a second issue with an attached patch is just confusing ;=) I closed the issue there.
I'm not sure if was ever not automatically saved, given my workflow, but the way it is now is destructive (and a nasty shock the first time I realized it had happened to me), as there is no way to retrieve a previous session state if you make an unintended action which changes it (like "close all" for example). I don't think a default of "on" on that eventual config option would be the best, since we should opt to be non-destructive by default. But yes, I do agree a config option would be good to have. I will try to submit the merge request as soon as I can. Thanks for looking into this.
Raphael are you still working on this patch on invent.kde.org?
Hi Justin, I got busied up with other things, I'll give the code another look and see if I can submit a merge request in the coming weeks. Thanks for the bump. Let me know if you have any suggestions for this, if they are simple enough I'll try my best to include them.
(In reply to Raphael Rosch from comment #10) > Hi Justin, I got busied up with other things, I'll give the code another > look and see if I can submit a merge request in the coming weeks. Thanks for > the bump. Let me know if you have any suggestions for this, if they are > simple enough I'll try my best to include them. No suggestions from me, but thank you for taking the time to improve KDE :)
Raphael working on a patch.
Hi, as said, I think the current behavior is wanted, but if we can have an option to disable auto-saving completely, that would be fine for me. For new contributions, please take a look at: https://kate-editor.org/post/2020/2020-07-18-contributing-via-gitlab-merge-requests/
With https://invent.kde.org/utilities/kate/-/merge_requests/1115 this is even more often auto-saved. I still think the current behavior is sane, if somebody wants to have this optional, please provide a patch.