bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behaviour change in 8.0 with empty input and no prompt


From: Kevin Pulo
Subject: Re: Behaviour change in 8.0 with empty input and no prompt
Date: Sat, 10 Dec 2022 21:14:19 +1100

On Thu, Nov 17, 2022 at 02:03:10AM +1100, Chet Ramey wrote:

> On 11/16/22 12:19 AM, Kevin Pulo wrote:
> >I noticed that in readline 8.0 and later, if there is no prompt and I
> >press Enter with an empty input line, readline does not output a
> >newline.  Earlier versions of readline did output a newline in this
> >situation.
> 
> Yes, since the cursor is at position 0 on an empty line, the readline
> redisplay suppresses the newline. This is the desired behavior when,
> for instance, you have multiple input lines and the cursor has just
> wrapped to the final line. Readline doesn't make a distinction between
> cases here, so your example also has the final newline suppressed.
> 
> >Was this change deliberate?  If so, is there a way to get the old
> >behaviour back (and if not, could an option be added)?  If the change
> >was not intentional, can it be considered a bug and the behaviour
> >reverted?
> 
> It's not a bug. It's a fix for this redisplay issue:
> 
> https://lists.gnu.org/archive/html/bug-readline/2018-09/msg00004.html

Got it, thanks for clarifying.

I definitely encounter this issue much more often than entering a line
which happens to be exactly as wide as the terminal.

> I could see making an exception if there is only one input line. Let me
> look at that.

Yes, I would prefer if the newline suppression logic could be tweaked
to handle this specific case.

I tried the attached patch (which just adds "|| rl_end == 0" to the
conditional in question) against the current devel branch.  Using
rlbasic to test the following 6 cases, it seems to be fine - the only
case that changed was the first (as desired).

1. empty input line
2. input line < screen width
3. input line == screen width (cursor at start of second line)
4. input line > screen width (cursor at end of second line)
5. input line == screen width (cursor moved back onto first line)
6. input line > screen width (cursor moved back onto first line)

Of course, there might be a cleaner way to do it, and there might also
be other affected scenarios (this code seems to have lots of edge
cases).

I would definitely be very appreciative if this patch (or equivalent /
better) could be merged - thanks!

Kev

Attachment: newline_when_empty.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]