GNOME Bugzilla – Bug 724777
When opening a non-existent file and then closing, don't ask for saving it
Last modified: 2014-03-03 13:12:32 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
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.
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
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.
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.
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.
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.
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.
Review of attachment 270766 [details] [review]: pushed thanks