Bug 353654 - Extend Kate's session to stash unsaved documents/changes on quit
Summary: Extend Kate's session to stash unsaved documents/changes on quit
Status: REOPENED
Alias: None
Product: kate
Classification: Applications
Component: sessions (show other bugs)
Version: unspecified
Platform: Other All
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 352440 375594 394833 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-10-07 14:12 UTC by Till Schäfer
Modified: 2024-03-06 14:11 UTC (History)
19 users (show)

See Also:
Latest Commit:
Version Fixed In: 21.04


Attachments
kate_session_configuration-page (35.92 KB, image/png)
2022-11-13 00:42 UTC, Piotr Mierzwinski
Details
kate version (13.10 KB, image/png)
2022-11-20 02:57 UTC, Piotr Mierzwinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Schäfer 2015-10-07 14:12:20 UTC
It would be nice to integrate a feature into session management, that allows the user to integrate temporary files / changes into its workflow. 

This is a typical workflow for me: 
- open kate and dump some ideas, notes, etc (at this point i am undecided, whether i would like to save the document on disk and especially where i would like to save the document)
- decide if the data i have created should be stored somewhere on the file system otherwise discard it

The problem with unsaved documents is, that they are lost on a crash (also see Bug 274102) and you may need to specify a file system location before rebooting your computer, closing kate, opening another session, etc. Therefore, you cannot simply save and restore your working state and continue your work without much hassle. Especially if you have created lots of temporary documents specifying a file system location is an extra burden that can be avoided.  

Integration into Session: 
- It should be possible to store the unsaved documents and changes inside a session. 
- On exit with unsaved documents the save/discard/cancel dialog should be extended to store unsaved documents / unsaved changes in the session. 
- Therefore, the session becomes some kind of stash (like in git). You can continue your work later without the need to save each document explicitly.


Reproducible: Always
Comment 1 Byte Smythe 2016-02-08 03:52:40 UTC
This is how Notepad++ behaves.  I never have to think about saving files or coming up with names.  I can just start a new document (or edit an existing one), start typing, and quit if I need to.  When I restart the editor, it automatically reopens all the documents in the same state I left them.
Comment 2 CnZhx 2016-02-20 10:40:16 UTC
I'd love this feature, too. It's especially valuable when Kate or system crashes which happens occasionally.
Comment 3 yes456 2016-04-15 07:56:37 UTC
+1 must have
Comment 4 yes456 2016-04-15 07:57:19 UTC
*** This bug has been confirmed by popular vote. ***
Comment 5 Nate Graham 2017-12-06 22:52:50 UTC
*** Bug 375594 has been marked as a duplicate of this bug. ***
Comment 6 Nate Graham 2017-12-06 22:52:56 UTC
*** Bug 352440 has been marked as a duplicate of this bug. ***
Comment 7 Nate Graham 2017-12-06 22:53:02 UTC
*** Bug 385275 has been marked as a duplicate of this bug. ***
Comment 8 Justin Zobel 2020-10-30 03:52:17 UTC
*** Bug 394833 has been marked as a duplicate of this bug. ***
Comment 9 Bug Janitor Service 2021-02-07 15:54:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/228
Comment 10 Christoph Cullmann 2021-03-05 07:50:43 UTC
Git commit 248b061111dffd57ac7879a6fb9abd20098d7441 by Christoph Cullmann, on behalf of Méven Car.
Committed on 05/03/2021 at 07:49.
Pushed by cullmann into branch 'master'.

Allow to stash changes on Close

M  +1    -0    kate/CMakeLists.txt
M  +7    -0    kate/katemainwindow.cpp
A  +97   -0    kate/katestashmanager.cpp     [License: LGPL(v2.0)]
A  +30   -0    kate/katestashmanager.h     [License: LGPL(v2.0)]

https://invent.kde.org/utilities/kate/commit/248b061111dffd57ac7879a6fb9abd20098d7441
Comment 11 Till Schäfer 2021-03-05 12:48:50 UTC
Woohoo, THX!
Comment 12 Piotr Mierzwinski 2021-08-24 21:30:39 UTC
I tested this in Neon updated at Jul, 24th 2021 (details below) and noticed that when I close kate with not saved file then it doesn't ask me for saving this file.  So this is what we expected.
The same happens when I have in kate not saved file and try to logoff or shutdown the system. Nice. Only the problem is that after kate  starts with new session of Plasma, the changes made before closing it are not restored, so nothing was swapped in moment on kate was closed. 

Second thing is that this (not asking for save not saved file) works only in Kate. When I tried to do the same with kwrite, it asked me for saving file. Please notice that I had the same setting in both.

BTW. I have 3 activities, but kate and krwite were tested only on one.

Kate 21.11.70
Plasma 5.22.80
Framework 5.85
Qt-5.15.3
Graphics X11
Kernel 5.8.0

I will retest this also with today;s Neon.
Comment 13 Piotr Mierzwinski 2021-08-24 21:42:54 UTC
As I promised, I retested kate in today's Neon.
Unfortunately in restored kate changes, which should be stashed wasn't restored. I got original file without any changes made before log out.

And kwrite blocks log out, asking for unsaved file.

Kate 21.11.70
Plasma 5.22.80
Framework 5.86
Qt-5.15.3
Graphics X11
Kernel 5.11.0-27-generic
Comment 14 Ganton 2022-04-03 20:47:48 UTC
There are unsaved changes when using Kate 21.08.1 if you open a session, create a new file, write something, wait two minutes and (for example) execute: killall -9 kate

Note: No data was lost when I used Kate 21.08.1, I opened a session, wrote something on an existing tab, waited two minutes and executed: killall -9 kate

Thanks!
Comment 15 Waqar Ahmed 2022-07-21 17:06:57 UTC
Please try with 22.04, a few fixes went into this which should hopefully resolve any remaining issues.

If it's not working die you still, first ensure you have a named session and the relevant config enabled (check sessions page in config dialog)
Comment 16 Torge 2022-11-10 12:12:58 UTC
Hi, this exactly sounds like what I need, but it does not work like I expect it to. Am I missing something?

Here is what I do:

1) Open Kate
2) Create new "Untitled" document
3) Write something into it
4) Wait a bit 
5) killall -9 kate
6) Reopen

I would expect the "Untitled" document to reappear with it's content. But they reappear empty.

I also tried with explicitly opening a session and doing it in that session.

Just to be clear, the issue I am fighting is, is data loss on system crash. And I don't want to have to save my quick thoughts each time I have them, to a specific file. This would be annoying. So I have basically the same issue as https://bugs.kde.org/show_bug.cgi?id=375594 which was deemed a duplicate of this.
Comment 17 Piotr Mierzwinski 2022-11-13 00:40:48 UTC
>  I would expect the "Untitled" document to reappear with it's content. But they reappear empty.

> I also tried with explicitly opening a session and doing it in that session.

> Just to be clear, the issue I am fighting is, is data loss on system crash. 

I would like to add that this doesn't work for me even if I kate is stopped by Plasma and started again with new Plasma session.  I have turned on restore session of Plasma and I experience loss data in Kate (for untilted documents) after Kate is restored  Please notice I don't have any activities and virtual desktops. This is really annoying. I have turned on proper option in settings of kate.
Comment 18 Piotr Mierzwinski 2022-11-13 00:42:21 UTC
Created attachment 153702 [details]
kate_session_configuration-page
Comment 19 Piotr Mierzwinski 2022-11-20 02:57:15 UTC
Created attachment 153891 [details]
kate version
Comment 20 Piotr Mierzwinski 2022-11-20 02:59:12 UTC
I tested this with Kate 23.03.70 and seems doesn't work.
In this moment I use Neon Unstable.
Comment 21 Nate Graham 2022-11-21 21:58:08 UTC
Crash robustness will require a different changes compared to restoring from a clean quit. Can you please file new bug reports--one per thing, if both are broken for you? In general it's best to open new bug reports rather than re-opening already fixed ones, since the conditions of what you're experiencing can be subtly different from what exactly was fixed. Thanks!
Comment 22 Piotr Mierzwinski 2022-11-21 23:29:17 UTC
(In reply to Nate Graham from comment #21)
> Crash robustness will require a different changes compared to restoring from
> a clean quit. Can you please file new bug reports--one per thing, if both
> are broken for you? In general it's best to open new bug reports rather than
> re-opening already fixed ones, since the conditions of what you're
> experiencing can be subtly different from what exactly was fixed. Thanks!

I opened:  Bug 46211
Comment 23 Nate Graham 2022-11-21 23:59:18 UTC
Correction: Bug 462112
Comment 24 Lorenzo 2023-12-15 08:24:40 UTC
I am using Kate 23.08.4 on Manjaro and this doesn't seem to work for me.

These are the settings for 'Sessions': https://gcdnb.pbrd.co/images/FtUBw5mWYTrD.png?o=1

I tried starting kate with kate -s and I get an untitled file. I add some text and quit (as expected no warning to save the file). But when I re-start kate the contents of the untitled file is lost. I'd expect the file and session to be saved and then restored based on the above options?

I did notice that when quitting for a second there is an orange line on the left highlighting changes ( I have this feature on) but then re-starting the changes are lost.
I think either the setting options are misleading or something is not working because the user gets no warning to save the file and this can lead to data loss
Comment 25 Florine W. Dekker 2024-03-06 14:11:13 UTC
@Lorenzo I think this is caused by bug #468573. You can find the old files using "Quick Open" (in menu as "Go > Quick Open", or use "Ctrl + Alt + O").