Bug 486746 - Untitled documents disappear from the working set when the user starts or stops debugging
Summary: Untitled documents disappear from the working set when the user starts or sto...
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: UI: general (show other bugs)
Version: 5.14.240480
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-07 17:51 UTC by Igor Kushnir
Modified: 2024-05-30 21:48 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.15.240800
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Kushnir 2024-05-07 17:51:17 UTC
SUMMARY
Working area change from Code to Debug or vise versa (but not from Code to Review and back) hides and makes inaccessible all untitled (unsaved) documents. Text entered in these documents is lost to the user, without any confirmation/save prompt. The open document counter is not decremented - new untitled documents contain greater numbers in their URLs after the older untitled documents disappear, so it appears the documents exist, but are inaccessible in the UI. Sometimes the few documents that became inaccessible most recently can be recovered from the Documents tool view or from the Most-Recently-Used Document Switcher.

STEPS TO REPRODUCE
1. Create one or more documents, (optionally) type text into them, but do not save them.
2. Start debugging.
3. (optionally) Repeat step 1.
4. Stop debugging.

OBSERVED RESULT
The untitled document tabs disappear and are absent from the Active Working Set.
KDevelop prints warnings like these:
kdevplatform.workingset: Unable to find file "file:///Untitled"
kdevplatform.workingset: Unable to find file "file:///Untitled (1)"

EXPECTED RESULT
The untitled document tabs are preserved when debugging is started or stopped.

ADDITIONAL INFORMATION
I suspect that this bug was introduced by the  merge request that introduced the printed warning: https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/213
Comment 1 Igor Kushnir 2024-05-07 18:35:45 UTC
This bug is sort of reverse of Bug 409858 fixed in the mentioned merge request.

Documents with a non-Untitled URL that don't have corresponding files on disk disappear when starting/stopping debugging too:
1. A nonexistent file opened by double-clicking a row in Breakpoints tool view.
2. A file that was opened in KDevelop editor, then deleted from disk externally.
Comment 2 Igor Kushnir 2024-05-09 11:07:36 UTC
(In reply to Igor Kushnir from comment #1)
> This bug is sort of reverse of Bug 409858 fixed in the mentioned merge request.
A simple fix that does not reopen Bug 409858 might work: skip opening nonexistent files only on KDevelop start, not when that function is called during a switch to a different area. Hopefully those nonexistent documents would be (re)opened correctly then.
Comment 3 Bug Janitor Service 2024-05-09 13:20:08 UTC
A possibly relevant merge request was started @ https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/559
Comment 4 Christoph Roick 2024-05-09 13:23:14 UTC
(In reply to Igor Kushnir from comment #2)
> (In reply to Igor Kushnir from comment #1)
> > This bug is sort of reverse of Bug 409858 fixed in the mentioned merge request.
> A simple fix that does not reopen Bug 409858 might work: skip opening
> nonexistent files only on KDevelop start, not when that function is called
> during a switch to a different area. Hopefully those nonexistent documents
> would be (re)opened correctly then.

I did something similar: Check if the document controller might actually find something with the temporary untitled name. If it does, take that document, if not, skip it. At startup it will not find the document. When switching between areas, it actually does.
Comment 5 Christoph Roick 2024-05-30 21:48:50 UTC
Git commit 9cc5682da37101b62eabd56437fd901c554b202c by Christoph Roick.
Committed on 30/05/2024 at 21:47.
Pushed by croick into branch 'master'.

Keep unsaved documents open when switching areas

The document controller can find unsaved files by specifying the
"untitled" document name as long as the controller exists. Show the
document if it is found.
FIXED-IN: 5.15.240800

M  +8    -0    kdevplatform/shell/tests/test_workingsets.cpp
M  +8    -2    kdevplatform/shell/workingsets/workingset.cpp

https://invent.kde.org/kdevelop/kdevelop/-/commit/9cc5682da37101b62eabd56437fd901c554b202c