Bug 322678 - Create new file when trying to open a nonexistent file
Summary: Create new file when trying to open a nonexistent file
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: All editors (show other bugs)
Version: 4.4.1
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2013-07-22 11:40 UTC by Alexander Potashev
Modified: 2014-04-06 01:31 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch (1.07 KB, patch)
2013-08-14 09:25 UTC, lycantrophe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Potashev 2013-07-22 11:40:04 UTC
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:
Comment 1 Kevin Funk 2013-07-23 06:30:05 UTC
One should have a look at the Kate editor, then... How is it implemented there? Patches welcome.
Comment 2 lycantrophe 2013-08-14 09:01:38 UTC
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.
Comment 3 lycantrophe 2013-08-14 09:25:36 UTC
Created attachment 81699 [details]
Patch

Removes the file-exists check.
Comment 4 lycantrophe 2013-08-14 09:27:12 UTC
I have submitted a patch that should solve this. I haven't found any regressions that should follow from this.
Comment 5 lycantrophe 2013-08-14 10:04:46 UTC
Here is the review: https://git.reviewboard.kde.org/r/112078/
Comment 6 lycantrophe 2013-09-21 21:49:22 UTC
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.
Comment 7 Aleix Pol 2013-10-24 19:38:26 UTC
This was already fixed, wasn't it?
Comment 8 lycantrophe 2013-10-25 07:39:26 UTC
It was, so this ticket can be closed.