Bug 486689 - File creation and saving File Dialog not coherent with current project context
Summary: File creation and saving File Dialog not coherent with current project context
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: file tree (other bugs)
Version First Reported In: 5.13.240202
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-06 21:11 UTC by Dominik Kummer
Modified: 2024-05-21 19:09 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 Dominik Kummer 2024-05-06 21:11:29 UTC
SUMMARY
During creation of new files into a new project structure within a session where multiple projects are open, the File Save Dialog does not propose the target directory as expected.

STEPS TO REPRODUCE
1. Open an existing projectA
2. Open a fileA1 from existing projectA
3. Create a new projectB, create subfolder 'srcB'
4. Create a new fileB1, save it within subfolder 'srcB'. Now two file tabs are visible in the following order: fileA1 and fileB1
5. Create a second fileB2, the tab of the yet unnamed file is placed next to fileB1 of projectB
6. Save the file, the file save dialog opens

OBSERVED RESULT
The file save dialog proposes the target directory of projectA. Even if the previous active file tab shows a file inside projectB. This is not intuitive.

EXPECTED RESULT
The file save dialog for unnamed files shall propose an intuitive target directory, especially when multiple projects are open.
* If it is the first open tab of an unnamed file, the proposed target directory shall be the current project selection.
* Otherwise if there are already tabs of saved files, the parent directory of the previous selected tab shall be proposed as target directory.
Comment 1 Igor Kushnir 2024-05-21 19:09:26 UTC
Kate does something similar to what you request: it uses the directory of the last active tab though (not the previous in the visible tab order). KDevelop ends up using the directory of some unspecified tab (possibly first in tab order). Here is why:
1. KTextEditor::DocumentPrivate::getSaveFileUrl() delegates the ordering to KTextEditor::Editor::instance()->application()->activeMainWindow()->views()  [we will try to get the url of the last used view, we assume some properly ordered views() list is around].
2. Kate returns KateMainWindow::views(), which delegates to KateViewManager::views() [@return all views sorted by their last use, most recently used first].
3. KDevelop returns KTextEditorIntegration::MainWindow::views(), which delegates to Sublime::Area::views() [@return the list of all views in this area in no particular order].

KDevelop's Most-Recently-Used Document Switcher plugin (Ctrl+Tab) maintains the list of documents sorted by their last use. So KDevelop could do the same as Kate. Might be difficult to implement properly though, because the list is in the plugin, not KDevPlatform. Maybe your proposed tab ordering would be easier to implement.

Note: I don't expect anyone to implement this feature any time soon, unless you scratch your own itch.