Bug 466553 - Switching sessions when a file has been modified or deleted creates mixed session
Summary: Switching sessions when a file has been modified or deleted creates mixed ses...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: sessions (other bugs)
Version First Reported In: 22.12.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-27 19:09 UTC by Grósz Dániel
Modified: 2024-10-20 18:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grósz Dániel 2023-02-27 19:09:33 UTC
SUMMARY
If an open file has been modified in Kate and/or deleted on disk, and you switch sessions, Kate asks you to confirm. If you click Cancel, Kate proceeds with opening the session you chose anyway. However, the files that were already open remain open according to the Documents sidebar, and get added to the newly opened session.

Switching back-and-forth in this manner can even result in the same file being open multiple times, independently.

STEPS TO REPRODUCE
1. Open some files, and save the session (Session 1).
2. Delete some of the open files on disk. (Alternatively, modify some files.)
3. Open another session from Sessions/Recent Sessions (Session 2).
4. When Kate asks "The file '...' was deleted on disk. Do you really want to continue to close this file? Data loss may occur.", click Cancel. (If you both modified some files and deleted them on disk, Kate first asks if you want Overwrite, Reload or Ignore Changes; then it asks if you want to Save, Discard or Cancel, choose Cancel.)

OBSERVED RESULT
Kate opens the files from Session 2, but files from Session 1 stay in the list of open files in the Documents sidebar, without being associated with any tab. Even if you quit Kate, and then start it again and choose Session 2, the files from Session 1 are opened too. If you open such a file from the Documents sidebar, it gets opened in a tab, and its contents are preserved if you haven't quit Kate and started it again, but if you did, and it's a file that was deleted on disk and not modified in Kate, it's opened as an empty file.

EXPECTED RESULT
Kate cancels the operation entirely. Session 1 remains open, and Session 2 isn't opened.

If the deleted files are not modified, it's also acceptable to close them without asking for confirmation. That's what happens if you delete a file on the disk that's open and not modified, and then close Kate without focusing the file's editor tab in the meantime.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20230226
KDE Plasma Version: 5.27.1
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.1.8-1-default (64-bit)
Graphics Platform: X11
Comment 1 Christoph Cullmann 2024-10-20 18:58:53 UTC
Git commit 75f83c07d5681d9254cc250701be76be2f4c09ca by Christoph Cullmann.
Committed on 20/10/2024 at 18:58.
Pushed by cullmann into branch 'master'.

abort session switch if we failed to close all things

M  +5    -2    apps/lib/session/katesessionmanager.cpp

https://invent.kde.org/utilities/kate/-/commit/75f83c07d5681d9254cc250701be76be2f4c09ca