The Kate editor has the following handy feature: if you try to open a non-existent text file, it creates a blank one and opens it. I would like KDevelop to have the same feature -- when you click File -> Open and choose a name for a file which does not yet exist, it should create a new file with the name typed in. This way of creating new files if better than using "Create File" in the Project tree's context menu, because the file open dialog opens in the current document's parent directory. "File -> Open" is also better because it has a shortcut (Ctrl+O) while one cannot assign a keyboard shortcut to "Create File". Well, it's possible to firstly create an untitled file and then save it under a desired name (Ctrl+N, Ctrl+S), but it's two actions in contrast to a single Ctrl+O. Reproducible: Always Actual Results: Expected Results:
One should have a look at the Kate editor, then... How is it implemented there? Patches welcome.
I've investigated this a bit. The code that manages this is chooseDocument() in kdevplatform/shell/documentcontroller.cpp Now, it calls openDocumentInternal which is supposed to handle it. It fails the check KIO::NetAccess::exists which makes it return without creating a document. I'm not sure of this is correct behaviour on exists' part, but assuming it is it is the following code that must be adjusted. The method that is used in the File->New file dialogue is a part of MainwinPrivate, and therefore not accessible. Someone who knows the details on how KDevelop handles documents should have a look at this.
Created attachment 81699 [details] Patch Removes the file-exists check.
I have submitted a patch that should solve this. I haven't found any regressions that should follow from this.
Here is the review: https://git.reviewboard.kde.org/r/112078/
https://git.reviewboard.kde.org/r/112078/ I updated the patch (with comments) to the reviewboard after irc discussions with Sven. Newer versions of Kate will create a message saying that a file has been created when opening a non-existent file.
This was already fixed, wasn't it?
It was, so this ticket can be closed.