Bug 385275

Summary: When exiting the application don't force user to save, unsaved document only save it as temporary
Product: [Applications] kate Reporter: Piotr Mierzwinski <piotr.mierzwinski>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: nate, piotr.mierzwinski, waqar.17a
Priority: NOR    
Version: 21.04.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: kwrite - File Opening & Saving
kwrite - File Opening & Saving-2
Screenshot of settings
Kate_Applicatio-Shutdown-behaviour
Kate session

Description Piotr Mierzwinski 2017-10-01 20:00:35 UTC
When exiting the application don't force user to save, unsaved document only save it as temporary/"not saved" in some safe place (maybe in the same directory as original one). And with next run of Kate just restore it, marked as unsaved.

This situation is a bit annoying when user want to leave system (login off, shut down computer) and from Kate pops up window - "Not saved document" which stops all shutting down process :/.

I met this feature in Notepad++ (one of the most popular text editor for Windows).
Comment 1 Nate Graham 2017-10-02 03:04:15 UTC
Apple's TextEdit does this, too.
Comment 2 Nate Graham 2017-12-06 22:20:06 UTC

*** This bug has been marked as a duplicate of bug 352440 ***
Comment 3 Nate Graham 2017-12-06 22:53:02 UTC

*** This bug has been marked as a duplicate of bug 353654 ***
Comment 4 Piotr Mierzwinski 2021-07-19 19:55:35 UTC
Created attachment 140201 [details]
kwrite - File Opening & Saving
Comment 5 Piotr Mierzwinski 2021-07-19 20:05:34 UTC
I'm not sure if bug which was linked with this one and fixed (at March), so Bug 353654 is actually related with this issue.
Anyway still I experience behaviour described below .  I mean every time kwrite asks me for saving, not saved document, when I close application or when try to log off or turn off my PC. 
Of course swap file option is turned on (check attached screen shot). I tested with default location and selected one. 
I tested this on newly created user.

KWrite  21.04.3
KDE Plasma Version: 5.22.3
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.2  (with KDE patches)
Kernel Version: 5.12.15-arch1-1 (64-bit)
Graphics Platform: X11
Operating System: Antergos Linux
Comment 6 Piotr Mierzwinski 2021-07-19 20:06:32 UTC
Created attachment 140202 [details]
kwrite - File Opening & Saving-2
Comment 7 Piotr Mierzwinski 2021-07-22 21:33:06 UTC
kio 5.84
kio-fuse 5.0.1
kdesdk-kioslaves 21.04.3
Comment 8 Piotr Mierzwinski 2021-07-26 20:01:06 UTC
I tested this also in Neon updated at Jul, 24th 2021 (details belwow) and noticed that when I close kate with not saved file then it doesn't ask me for saveing this file. The same is happen 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 then changes made before closing are not restored, so nothing was swapped in moment on kate was closed. 
Second thing is that this (not asking for file save not saved file) works only in Kate. When I tried to do the same with kwrite, it asked me for saveing file. Please notice that I had the same setting in both.

Kate 21.11.70
Plasma 5.22.80
Framework 5.85
Qt-5.15.3
Graphics X11
Kernel 5.8.0
Comment 9 Waqar Ahmed 2022-02-22 19:19:11 UTC
> Only the problem is that after kate  starts with new session of Plasma then changes made before closing are not restored, so nothing was swapped in moment on kate was closed. 
Second thing is that this (not asking for file save not saved file) works only in Kate. When I tried to do the same with kwrite, it asked me for saveing file. Please notice that I had the same setting in both.

New bugs for new issues. The feature is implemented now (which this bug is about) but we need to refine it more, so please open a new bug with steps on how to reproduce the bug you are facing.
Comment 10 Piotr Mierzwinski 2022-02-23 02:27:40 UTC
> Second thing is that this (not asking for file save not saved file) works only in Kate. When I tried to do the same with kwrite, it asked me for 
> saveing file. Please notice that I had the same setting in both.

>New bugs for new issues. The feature is implemented now (which this bug is about) but we need to refine it more, so please open a new bug 
> with steps on how to reproduce the bug you are facing.

Yes you are right. Sorry I mixed the things.
Anyway, as I described in post sent at 2021-07-26 22:01:06 CEST  feature doesn't work well for Kate. Nothing not saved back when the Plasma session is restored.
Also would be nice to have this feature in KWrite also.
I will open new bug report for Kate and a wish for KWrite.
Comment 11 Waqar Ahmed 2022-02-23 06:18:53 UTC
> Anyway, as I described in post sent at 2021-07-26 22:01:06 CEST  feature doesn't work well for Kate. Nothing not saved back when the Plasma session is restored.

I don't understand what you mean by "Plasma session is restored". This is why I asked you for a new bug and detailed steps.

We fixed a bug with restoration very recently (22.04) though, so maybe the issue you are facing is already gone.
Comment 12 Piotr Mierzwinski 2022-02-23 21:37:02 UTC
(In reply to Waqar Ahmed from comment #11)
> > Anyway, as I described in post sent at 2021-07-26 22:01:06 CEST  feature doesn't work well for Kate. Nothing not saved back when the Plasma session is restored.
> 
> I don't understand what you mean by "Plasma session is restored". This is
> why I asked you for a new bug and detailed steps.
OK. Maybe I used misleading words. I meant "Desktop session".
I have checked following option in System Settings: Workspace -> Desktop Session -> When logged in: Restore previous saved session", so after next log in I get all recently opened windows (applications). Kate is run of course, but all not saved changes in modified file, which i left before log off, disappearing. So unsaved changes are not restored.


> We fixed a bug with restoration very recently (22.04) though, so maybe the
> issue you are facing is already gone.
I tested this in recent Neon, so I update it ~22:15 today. Kate version is 22.03.70, KFramework 5.92
Unfortunately it doesn't work at all.
Simple test I made was.
1. Run Kate with its saved session. 
2. Modified one file
3. After ~1min. I logged off
4. I logged in again
Checked Kate and found that all my changes gone.
Settings in Kate:
Swap file mode: Enabled, Save in Custom Directory
and here I have location where I can write.
Comment 13 Waqar Ahmed 2022-02-24 05:35:58 UTC
Dont reopen bugs that are fixed.

Secondly, maybe your bugs is in plasma i.e., maybe it doesn't start kate correctly. Or maybe its already fixed as mentioned above.
Comment 14 Piotr Mierzwinski 2022-02-24 17:32:56 UTC
(In reply to Waqar Ahmed from comment #13)
> Dont reopen bugs that are fixed.
Sorry, but from my point of view isn't fixed, rather is fixed partially because Kate doesn't complain about save when is closing with not saved document. Nevertheless seems document isn't save as temporary, otherwise would be reloaded properly after next start of Kate. I understand this like that. 

> Secondly, maybe your bugs is in plasma i.e., maybe it doesn't start kate
> correctly. Or maybe its already fixed as mentioned above.
What do you mean "doesn't start kate correctly"?
After next login, desktop session is restored and I can see opened Kate with its session, but document changed previously, and not saved  it' not loaded. How can I identify that Kate doesn't start correctly?
I don't see any error messages.

Did you test this issue with my settings, so I mean when desktop session is restored?
Comment 15 Waqar Ahmed 2022-02-24 17:42:36 UTC
Created attachment 147104 [details]
Screenshot of settings

Can you check if you have the settings in linked screenshot enabled?
Comment 16 Piotr Mierzwinski 2022-02-25 21:00:22 UTC
Created attachment 147121 [details]
Kate_Applicatio-Shutdown-behaviour
Comment 17 Piotr Mierzwinski 2022-02-25 21:01:21 UTC
(In reply to Waqar Ahmed from comment #15)
> Created attachment 147104 [details]
> Screenshot of settings
> 
> Can you check if you have the settings in linked screenshot enabled?

Today update Neon just after 8pm. Opened Kate and found that I have checked both right option (check attachment).
I made the same test, so modified file, logged out and logged in.  In result nothing was restored, all changes gone.
Comment 18 Piotr Mierzwinski 2022-02-25 21:06:12 UTC
Simple test when I manually closed Kate and run it again (without logging out) gave the same result - all changes gone.
Thanks that test I know that this is not the issue with restoring desktop session.
Comment 19 Waqar Ahmed 2022-02-25 21:08:38 UTC
Do you have a session?

Try the following

- kate -s new_session
- type something
- hit X - close kate

Reopen kate using the same command: "kate -s new_session"
Comment 20 Waqar Ahmed 2022-02-25 21:09:12 UTC
The above works for me, haven't noticed any issues lately with that.
Comment 21 Piotr Mierzwinski 2022-02-25 21:53:34 UTC
(In reply to Waqar Ahmed from comment #19)
> Do you have a session?
> 
> Try the following
> 
> - kate -s new_session
> - type something
> - hit X - close kate
> 
> Reopen kate using the same command: "kate -s new_session"

Yes. I had a session (check screenshot) . I opened: "Session -> Quick Open session -> Anonymous"  and in next window I clicked "Discard"> After that view of Kate window changed and ,magically my changes appeared. Seems something was cached incorrectly. 

Your scenario works.

I wonder why when I  use "New session" from option "Session" I don't get any question for new session name only is opened new document. I open new, modify, try to close and Kate asks me for saving. So seems any (default) session wasn't created. If this doesn't work, so I'm not I'm not able to create new session from GUI. When I do the same using option "Manage Session -> New Session" I get the same result. Please check this. I can raise bug for this if you confirm that this is the bug.
Comment 22 Piotr Mierzwinski 2022-02-25 21:54:39 UTC
Created attachment 147122 [details]
Kate session
Comment 23 Piotr Mierzwinski 2022-02-25 21:55:58 UTC
> Reopen kate using the same command: "kate -s new_session"

It works even I just open again Kate (I have checked option to open last session)
Comment 24 Piotr Mierzwinski 2022-02-25 22:13:15 UTC
Shame this behavior is linked with session only, and not with single file like it happens in Notepad++. 
I hope that also Kwrite will get such feature.