https://bugs.kde.org/show_bug.cgi?id=447384
Bug ID: 447384 Summary: Session restore only restores 'windows'/'tabs' viewspace state for a maximum of one stashed document (that is not yet saved), despite many others being present on session save Product: kate Version: 21.12.0 Platform: Microsoft Windows OS: Microsoft Windows Status: REPORTED Severity: normal Priority: NOR Component: application Assignee: kwrite-bugs-n...@kde.org Reporter: dominic.pal...@outlook.com Target Milestone: --- SUMMARY For context, I have been looking into Kate as a personal replacement for Notepad++. There has long been scope for another editor to challenge Notepad++'s functionality whereby: 1. Untitled/unsaved/anonymous files can be created freely and populated with text as normal. 2. On closing Notepad++, any untitled files with non-empty text content are written to disk in a temp folder, and the session state (including window and tab placement of the untitled files) is stored. 3. On reopening Notepad++, any untitled files are popped from disk and the window/tab/session state is fully recovered. Much of this functionality is now present in Kate through sessions and stashes. A 'God' session can be created, such that provided no other sessions are created, Kate will always reopen and restore it at startup ('always open most recent session'). List item 1 above is also possible through Kate - unsaved files can be added to a session at will. List item 2 is implemented - the addition of KateStashManager means that unsaved documents are now pushed to a stash on close (via KateStashManager::stashDocuments in katestashmanager.cpp, lines 42-72, provided the text content is non-empty) and popped on restore. The issue is that on session restore, the window/tab state of _at most one_ unsaved document that was stashed is restored. This means that a user could have a session with 5 untitled/unsaved documents open, all populated with text, and close Kate. On reopening, just one of those untitled sessions will have a window/tab reopened for it, despite all untitled sessions being visible in the documents toolbar. This means that the document content IS being correctly popped on restore and reflected in the documents tree, but either: 1. Window/tab/viewspace state for untitled documents is not saved in config, and hence can't be restored OR 2. Window/tab/viewspace state for untitled documents is saved, but not restored on startup A potentially unrelated but similar issue is that the state of the document tree is not restored either, for both untitled and titled (i.e., previously saved files w/ a checksum). The document tree toolbar only expands the directory of any file in the active window. The state of the tree on session close or the last session save is ignored. This leads me to wonder whether more data in general needs to be written to <session>.katesession on save. STEPS TO REPRODUCE 1. Start a new Kate session. Open 1 file that is already stored on disk for reference. Add 2 new untitled/unsaved files to the session. 2. In the untitled files, add some random text content. This will force Kate to stash the document on session close/save. 3. Configure Kate to save the session on close, and reopen the most recent session on startup. 4. Have the active window open on the file already stored on disk, but make sure that both untitled files have tabs open regardless. 5. Close Kate. 6. Reopen. OBSERVED RESULT The window state will be restored such that the file stored on disk has a tab, yet just ONE of the 2 untitled files will have a tab. All 3 files will be present in the document tree toolbar despite this. EXPECTED RESULT The exact window state at the point of session save should have been stashed and restored on startup. This means that all 3 files (1 on disk, 2 untitled) should have tabs already open. The state of the document tree should also be preserved, and shouldn't only expand directories for the file currently in the active window. SOFTWARE/OS VERSIONS Windows: Windows 10 Pro 21H1 19043.1415 macOS: N/A Linux/KDE Plasma: N/A (available in About System) KDE Plasma Version: N/A KDE Frameworks Version: N/A Qt Version: N/A ADDITIONAL INFORMATION To fully capture users who use Notepad++ for persistence of temporary unsaved files, it may also be worth looking into enforcing the right click -> Open with Kate menu to open the file with the last used session. At the moment, Kate will create a new anonymous session when using this menu (if Kate isn't already open), regardless of whether it's configured to open the most recent session. -- You are receiving this mail because: You are watching all bug changes.