nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] fixing bug #51040


From: Viorel Bota
Subject: [Nano-devel] fixing bug #51040
Date: Mon, 25 Sep 2017 22:25:33 +0300

With the new patch (0001-files-check-for-a-changed-disk-file-also-for-savefil.patch)

Behaviour 1:
        if the user uses --tempfile
        and the file changed on disk
        and user attempts exit by pressing "^x" and selecting option "Y" (Yes)
        then the file buffer is written to the disk but nano does not exit.
   
    This does not feels natural. Since you have to press "^x" a second time to exit nano.

    Also this is different form the situation where --tempfile is not used
        if the user does not use --tempfile
        and the file changed on disk
        and user attempts exit by pressing "^x" and selecting option "Yes"
        then the file buffer is written to the disk and nano is stopped
   
Behaviour 2:
    As you indicated:
    if the user uses --tempfile
    and the file changed on disk
    and user attempts exit by pressing "^x" and selecting option "N" (No)
    then nano does nothing exactly as if the user would select "^c" (Cancel)
   
    This is also different from the situation where --tempfile is not used:
        if the user uses --tempfile
        and the file changed on disk
        and user attempts exit by pressing "^x" and selecting option "N" (No)
        then the file is not written to the drive and nano is exited
       
Question 1:
    should nano have the same behavior:
    when using --tempfile or not
    and the user pressed "^x" then selects option "N" (No)?
   
Question 2:   
    should we make nano discard changes and exit when the user pressed "^x" then select option "N" (No)?



On Sun, 24 Sep 2017 12:45:23 +0200
From: Benno Schulenberg <address@hidden>
To: address@hidden
Subject: [Nano-devel] fixing bug #51040
Message-ID: <8e7b3402-3bb0-6e83-5613-address@hidden>
Content-Type: text/plain; charset="utf-8"; Format="flowed"


Op 21-09-2017 om 00:52 schreef Viorel Bota:
> I followed your indications and implemented a proposal that avoids duplicating code.
>
> Changes remain isolated in the function "do_writeout(bool exiting)" from source
> file "files.c".
>
> The solution is in the attachment.

Thanks.  The patch... mostly works.  But it forgets to initialize i to 0,
and when using --tempfile and writing of the file fails (because the file
was made unwritable in the meantime, say), it becomes impossible to exit
from nano when the buffer was modified.

Furthermore, when the "File was modified" prompt comes up and you press ^C,
the prompt bar is not cleared.  And when the user answers "No", nano should
probably act the same as for Cancel -- it should only discard the buffer if
the user actively chooses to do so, via ^O ^Q.

All these problems are easily fixed, so I have done that.

Your patch also *improves* the behavior of nano when --tempfile is used
and writing of the modified buffer fails.  Currently, when that happens,
there is no error message, there is no indication why the writing failed,
nano immediately goes on to prompt for a file name.  My first response was
to press ^C and then try ^X again.  Same result.  Your patch changes this
so that nano just shows the error message and takes no further action,
which I like better.

In the attached patch I have fixed all the above issues, and adjusted all
the formatting and whitespace errors as well.  Please test, and report
whether you are okay with this version, Viorel.

Oh!  Only after changing all that, I realize that the patch does not cover
the case of 'savefile'!  I now have fixed that too, by adding a parameter
to do_ write_out(), as predicted.

Benno
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-files-check-for-a-changed-disk-file-also-for-savefil.patch
Type: text/x-patch
Size: 4995 bytes
Desc: not available
URL: <http://lists.gnu.org/archive/html/nano-devel/attachments/20170924/33d0d366/attachment.bin>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]