bugGNU nano - Bugs: bug #48852, when the terminal is narrow, the...

 
 

bug #48852: when the terminal is narrow, the cursor is placed wrongly in the prompt bar

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Mon 22 Aug 2016 09:54:04 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.

 

(Jump to the original submission Jump to the original submission)

Thu 25 Aug 2016 09:09:32 AM UTC, comment #7:

The problem has been reported upstream (https://lists.gnu.org/archive/html/bug-ncurses/2016-08/msg00021.html) and it appears to be partly a bug in VTE, and partly an optimization in ncurses (which goes wrong when COLS does not match the real right margin of the terminal).

A workaround for these was added in git, c22cd03.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Wed 24 Aug 2016 09:48:00 AM UTC, comment #6:

When in src/global.c you change N_("Prepend") to N_("Prep"), and run 'stty cols 27 && LANGUAGE=en src/nano --ignore NEWS && stty cols 120' and type ^O, the cursor is placed correctly. When you add back an "e" to make it N_("Prepe"), the cursor is placed wrongly.

So the trigger is: writing the very last character of the bottomwin subwindow. But... not always. Because if you run 'stty cols 27 && LANGUAGE=en src/nano --ignore --nohelp --bold NEWS && stty cols 120', the cursor is placed fine (but blank_statusbar() still writes the very last char of the subwindow; so how come?). When you leave out the --bold, the cursor is placed wrong. Pah.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 22 Aug 2016 08:15:39 PM UTC, comment #5:

Ugh. It can't be fixed. Apply the attached patch, which fixes the --ignorercfiles case. But now run 'stty cols 27 && LANGUAGE=en src/nano --ignore --nohelp NEWS', and see how the cursor is still placed wrong. Press <Left> four times -- upon the third <Left>, the cursor jumps two places. The cursor never lands on the W. When you put it on the S (meaning it is in fact on the W) and type xx, the exes get inserted before the W. Bleh! What the smurf is going on?

(file #38321)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 22 Aug 2016 06:09:22 PM UTC, comment #4:

The bug is in ncurses. To prove it, apply the attached patch, run 'stty cols 27 && LANGUAGE=en src/nano NEWS', press ^O, wait for the beep, press <Left> at least four times, then press ^G ^G. Both before and after the ^Gs, the cursor is placed wrongly: on the E of NEWS.

Now comment out the first of added doupdate()s, compile, and run the same command and do the same keystrokes again. After the ^Gs, the cursor is now placed correctly: on the N of NEWS. We update less, and the cursor is placed better... Somehow ncurses does not work right on these terminal emulators.

It is time again for a forced line redraw. :(

(file #38317)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 22 Aug 2016 01:39:39 PM UTC, comment #3:

On a Linux console, the cursor is placed always correctly. On a VTE or an xterm, if the cursor is placed wrong and you do a <Left> followed by a ^G ^G, the cursor will be placed correctly -- and will stay placed correctly as long as you don't do a ^G ^G again while the cursor is in the last two possible columns.

Doing 'stty cols 27 && LANGUAGE=en src/nano NEWS', the cursor will be placed one position beyond its true position. Using instead "cols 28", it will be placed fine. Totally bonkers!

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 22 Aug 2016 11:41:44 AM UTC, comment #2:

Run 'stty cols 12 && src/nano --ignore --nohelp NEWS', then type ^O <Left> <Left> <Left> <Left>. The statusbar ends with ":$ N", which is wrong. Now press ^G ^G. Now the statusbar ends with ": N ", which is better -- but the cursor is placed not on the N but after it, and the space after the N should be a $.

Now press <Right>. Result ": $E". Press ^G ^G. Result: ":$E ". Hrrrmm... Why does the position change by a simple repainting?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 22 Aug 2016 10:09:27 AM UTC, comment #1:

Hrm. When using '--ignore --nohelp --bold', the cursor is placed correctly. When leaving out the --bold, the cursor is placed wrong. Also when in the .nanorc file a titlecolor is given, the cursor is placed correctly with --nohelp. Maybe I'm looking at a bug in ncurses here.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 22 Aug 2016 09:54:04 AM UTC, original submission:

To reproduce, do 'stty cols 12 && src/nano --ignore NEWS' and type ^O. The prompt bar will show: "File Nam:$ C" (where C is the cursor). When you press <Left> a few times, it will show each of the letters of "NEWS" at the very end of the prompt bar, instead of right after the $. When you then press <Right>, it will show an extra $: "File Nam:$$C". Which is wrong.

Before version 2.3.3 it would correctly show: "File Nam:$C ".

The offending commit is 8977c4b. Which is weird! It shouldn't affect the prompt bar at all. Aaah... But it doesn't. When using --nohelp, the cursor is always placed wrongly on a narrow terminal, since at least version 2.2.1.

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:
   

 

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
    Fri 02 Sep 2016 07:38:36 AM UTCbensOpen/ClosedOpen=>Closed
    Thu 25 Aug 2016 09:09:32 AM UTCbensStatusConfirmed=>Fixed
    Wed 24 Aug 2016 09:48:00 AM UTCbensStatusIn Progress=>Confirmed
    Mon 22 Aug 2016 08:15:39 PM UTCbensAttached File-=>Added 0001-statusbar-place-the-cursor-correctly-also-when-near-.patch, #38321
    Mon 22 Aug 2016 06:09:22 PM UTCbensAttached File-=>Added proving-the-point.patch, #38317
      StatusNone=>In Progress

    Back to the top


    Powered by Savane 3.1-cleanup1