bugGNU nano - Bugs: bug #46414, undoing the insertion of a file...

 
 

bug #46414: undoing the insertion of a file that doesn't end in a newline goes wrong

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Tue 10 Nov 2015 05:15:24 PM UTC  
 
Severity: 4 - ImportantStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 13 Nov 2015 09:58:09 AM UTC, comment #5:

Fixed in SVN, r5404.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Wed 11 Nov 2015 02:30:10 PM UTC, comment #4:

The previous patch leaves an unfinished undo item in the list when the reading of the file or the execution of the command fails, which would lead to a segfault later on when trying to undo this unfinished item.

New patch is much less invasive: if the insertion is just a single line, simply remember the cursor position; otherwise, remember how long the last line of the insertion is. When the insertion ends in a newline, the length of the last line will be zero and things will be as they were, but when the last line contains stuff, now an undo will also undo that part, and upon a redo the cursor will be properly put back after it.

(file #35434)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 10 Nov 2015 09:46:32 PM UTC, comment #3:

First attempt at a patch. Works for me, but probably could use some refinements.

(file #35432)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 10 Nov 2015 05:27:50 PM UTC, comment #2:

Bug has been present since at least nano-2.2.5.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 10 Nov 2015 05:18:48 PM UTC, comment #1:

Oh, and trying to redo the insertion then segfaults.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 10 Nov 2015 05:15:24 PM UTC, original submission:

When NONEWLINES is set, and having read in a file that does not end in a newline, then trying to undo it leaves the last line in place.

To reproduce, do 'echo -n word >oneword', then run 'src/nano --ignore --nonew README'. Then type: ^R oneword <Enter> M-U.
See how the cursor moves back to the start of the line but the "word" stays there.

(The undoing works fine when --nonewlines isn't given (because nano will add a newline after the read-in stuff), or when leaving out the '-n' from the echo command.)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #35434:  undoing-an-insertion-right.patch added by bens (1KiB - text/x-diff - correctly determines the cursor position after an insertion)
file #35432:  properly-undo-insert.patch added by bens (2KiB - text/x-diff - puts the add_undo and update_undo in better places)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bens (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 07 Dec 2015 03:17:56 PM UTCbensOpen/ClosedOpen=>Closed
    Fri 13 Nov 2015 09:58:09 AM UTCbensStatusReady For Test=>Fixed
    Wed 11 Nov 2015 02:30:10 PM UTCbensAttached File-=>Added undoing-an-insertion-right.patch, #35434
    Tue 10 Nov 2015 09:46:32 PM UTCbensAttached File-=>Added properly-undo-insert.patch, #35432
      StatusNone=>Ready For Test
      Summaryreading in a file that doesn\'t end in a newline isn\'t properly undone=>undoing the insertion of a file that doesn't end in a newline goes wrong
    Tue 10 Nov 2015 05:18:48 PM UTCbensSeverity3 - Normal=>4 - Important

    Back to the top


    Powered by Savane 3.1-cleanup1