bugGNU nano - Bugs: bug #50135, nano makes too many replacements...

 
 

bug #50135: nano makes too many replacements when 'from' and 'to' are nearly equal

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Tue 24 Jan 2017 10:20:05 AM UTC  
 
Severity: 3 - NormalStatus: 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.

 

Wed 25 Jan 2017 10:38:08 AM UTC, comment #2:

Fixed in git, 3534d8ff.

It now does just two replacements (in the forward direction) and puts the cursor back where it was.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 24 Jan 2017 01:21:44 PM UTC, comment #1:

The "hanging" issue mentioned near the end has been reported separately as bug #50137. So this bug is just about the making of too many replacements in the current line in the forward direction.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 24 Jan 2017 10:20:05 AM UTC, original submission:

To reproduce, run 'echo xxx >exes' and then 'nano --ignore exes'. Then type: M-R xx <Enter> xxx <Enter>. Then type Y for every prompt. Nano asks /three/ times: first for the final two xx, then for the first two, and then again for the final two. Wrong. And after the three replacements, the cursor sits at the /end/ of the line, instead of at the beginning. Wrong too.

One might expect nano to ask only once: for the first two, and that should be it. But since nano will not start replacing right where the cursor is but one step beyond, it would be defensible that nano asked twice: for the final two, and then, wrapping around, for the first two. But that should then really be it, because the cursor has reached the starting point.

This bug is old too, since at least nano-2.0.2.

In current git, the behavior is even worse, although somehow more understandable: it does /four/ replacements.

For comparison: doing the replacements backwards:
M-R M-B xx <Enter> xxx <Enter>
will do just two replacements, in all released versions of nano. In current git it will "hang": it will do infinite replacements, because it never seems to move the cursor from where it found the first match.

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:
   

No files currently attached

 

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 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 24 Feb 2017 10:34:10 AM UTCbensOpen/ClosedOpen=>Closed
    Wed 25 Jan 2017 10:38:08 AM UTCbensStatusIn Progress=>Fixed
    Tue 24 Jan 2017 01:21:44 PM UTCbensStatusNone=>In Progress
      Assigned toNone=>bens

    Back to the top


    Powered by Savane 3.1-cleanup1