After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724777 - When opening a non-existent file and then closing, don't ask for saving it
When opening a non-existent file and then closing, don't ask for saving it
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: file loading and saving
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2014-02-20 07:19 UTC by Fabian Greffrath
Modified: 2014-03-03 13:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug 724777 When opening a non-existent file and then closing, don't ask for saving it (672 bytes, patch)
2014-02-20 11:37 UTC, Sagar Ghuge
needs-work Details | Review
Bug 724777 When opening a non-existent file and then closing, don't ask for saving it (1.64 KB, patch)
2014-02-24 06:25 UTC, Sagar Ghuge
none Details | Review
Bug 724777 When opening a non-existent file and then closing, don't ask for saving it (1.69 KB, patch)
2014-02-26 07:14 UTC, Sagar Ghuge
none Details | Review
Bug 724777 When opening a non-existent file and then closing, don't ask for saving it (1.69 KB, patch)
2014-02-27 10:11 UTC, Sagar Ghuge
none Details | Review
Bug 724777 When opening a non-existent file and then closing, don't ask for saving it (996 bytes, patch)
2014-02-27 11:38 UTC, Sagar Ghuge
none Details | Review
Bug 724777 When opening a non-existent file and then closing, don't ask for saving it (1.20 KB, patch)
2014-03-03 10:36 UTC, Sagar Ghuge
committed Details | Review

Description Fabian Greffrath 2014-02-20 07:19:44 UTC
Hi,

it happens regularly that I open a file from a terminal that does not actually exist. For example, I have a file called "code.c" and forget that it is already compiled and thus "code.o" is also present. If I want to edit the source file, I am lazy and type "gedit code.", then hit Tab and then Enter. Since both files with .c and .o extensions exist, Tab completion is not umambigious and hitting Enter then leads to opening a file called "code." - which actually does not exist.

So, Gedit presents me an empty "code." file, which is fine. However, whenever i attempt to close its window Gedit asks me if I want to save that file. This is really annoying, because I haven't changed that file at all- in fact, it doesn't even exist!

TL;DR: When opening a non-existent file and closing its window without any changes, please refrain from asking me if I want to save that file. BTW, vim already behaves like this and it is really convenient.

 - Fabian
Comment 1 Sagar Ghuge 2014-02-20 11:37:23 UTC
Created attachment 269792 [details] [review]
Bug 724777  When opening a non-existent file and then closing, don't ask for saving it

If buffer is not modified then it returns FALSE.
Comment 2 Paolo Borelli 2014-02-20 17:27:25 UTC
Review of attachment 269792 [details] [review]:

This is not correct, by placing the "else" everything that comes later in this function is never executed.

You need to store a flag variable in priv that says if this is a "new file" and then use it to skip the "deleted/modified" checks
Comment 3 Sagar Ghuge 2014-02-24 06:25:33 UTC
Created attachment 270094 [details] [review]
Bug 724777  When opening a non-existent file and then closing, don't ask for saving it

Added a new_unmodified flag.
Comment 4 Sagar Ghuge 2014-02-26 07:14:55 UTC
Created attachment 270351 [details] [review]
Bug 724777  When opening a non-existent file and then closing, don't ask for saving it

new_unmodified set in gedit_document_load only if create is true.
Comment 5 Sagar Ghuge 2014-02-27 10:11:59 UTC
Created attachment 270452 [details] [review]
Bug 724777  When opening a non-existent file and then closing, don't ask for saving it

_gedit_document_needs_saving() factorized.
Comment 6 Sagar Ghuge 2014-02-27 11:38:38 UTC
Created attachment 270463 [details] [review]
Bug 724777  When opening a non-existent file and then closing, don't ask for saving it

new_unmodified removed.
Comment 7 Sagar Ghuge 2014-03-03 10:36:14 UTC
Created attachment 270766 [details] [review]
Bug 724777  When opening a non-existent file and then closing, don't ask for saving it

doc->priv->create cleared.
Comment 8 Paolo Borelli 2014-03-03 13:12:18 UTC
Review of attachment 270766 [details] [review]:

pushed thanks