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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

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

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

Fixed in SVN, r5404.

Benno Schulenberg <bens>
Group administrator
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>
Group administrator
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>
Group administrator
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>
Group administrator
Tue 10 Nov 2015 05:18:48 PM UTC, comment #1: 

Oh, and trying to redo the insertion then segfaults.

Benno Schulenberg <bens>
Group administrator
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>
Group administrator

 

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

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
  • -email is unavailable- added by bens (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-07 bens Open/ClosedOpen Closed
    2015-11-13 bens StatusReady For Test Fixed
    2015-11-11 bens Attached File- Added undoing-an-insertion-right.patch, #35434
    2015-11-10 bens Attached 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
    2015-11-10 bens Severity3 - Normal 4 - Important

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code