bugGNU nano - Bugs: bug #48627, doing a <Right> at the end...

 
 

bug #48627: doing a <Right> at the end of a long line, redraws the next line twice

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Mon 25 Jul 2016 03:08:28 PM UTC  
 
Severity: 2 - MinorStatus: 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.

 

Mon 01 Aug 2016 06:06:17 PM UTC, comment #3:

Fixed in git, c9e9964.

What isn't fixed yet, though, is a <Ctrl+Right> at the end of a horizontally scrolled line -- that still redraws the target line unnecessarily. Fixing that will require passing the old xplustabs position to edit_redraw(). Bleh...

(Instead of computing this xplustabs at every corner, it would be better to just store it next to current_x in the openfile struct: openfile->current_column.)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 26 Jul 2016 10:46:14 AM UTC, comment #2:

No, it is not the x position that matters, but the xplustabs position. (Which is a misnomer, by the way, because it also reckons with multicolumn characters.) So what should be compared is: the actual column positions before and after the move.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 26 Jul 2016 08:34:33 AM UTC, comment #1:

Attached is a first smurf that avoids the needless redrawings of lines in the case of simple cursor movements (without any vertical scrolling). There are still needless redrawings in edit_redraw(), but that is something for an other bug.

The patch is rough -- it will require some renaming and regrouping of things later. This is just to get the correct behavior while changing as few lines as possible.

The basic idea is that, for deciding whether a line needs to be redrawn (that is: horizontally scrolled), the placewewant is irrelevant. What matters is: what the actual old x position was and what the actual new x position is. If those two are on different "pages", then redraw the line.

(file #38027)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 25 Jul 2016 03:08:28 PM UTC, original submission:

To reproduce, first create a file named 'double', with two long lines that are two characters shorter than the width of the terminal -- meaning that when you type one extra character at the end of the line, the line will scroll horizontally. Save the file and exit, and then apply the attached patch.

Then start 'src/nano double'. It beeps as each of the three lines is drawn (the empty third line is drawn too). Now verify that moving the cursor around will not redraw any of the lines -- not either when the cursor is moved with <Right> from the end of the first line to the beginning of the second.

Now add one character to the start of each line and type <End> on the first line. The line is redrawn, because it now is horizontally scrolled. Then type <Right>. The first line is redrawn, which is correct, because it needs to be unscrolled. But then... line 2 is redrawn scrolled and then again redrawn unscrolled. Buuh! It shouldn't have been redrawn at all -- there was no need!

Now type <Left> -- only line 1 is redrawn. Correct, that is how it should work. Now do <Ctrl+Right> -- line 2 is redrawn once. That's better, but still overkill.

Expected behavior: a line that is not horizontally scrolled, should never be redrawn. It's a waste of time and battery life.

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 #38027:  use-the-x-position.patch added by bens (6KiB - text/x-diff)
file #38022:  show-redraws.patch added by bens (414B - text/x-diff)

 

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

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 11 Aug 2016 10:52:20 AM UTCbensOpen/ClosedOpen=>Closed
    Mon 01 Aug 2016 06:06:17 PM UTCbensStatusIn Progress=>Fixed
      Summarydoing <Right> at the end of a long line, redraws next line twice=>doing a at the end of a long line, redraws the next line twice
    Tue 26 Jul 2016 08:34:33 AM UTCbensAttached File-=>Added use-the-x-position.patch, #38027
      StatusNone=>In Progress
    Mon 25 Jul 2016 03:08:28 PM UTCbensAttached File-=>Added show-redraws.patch, #38022

    Back to the top


    Powered by Savane 3.1-cleanup1