bug-bash
[Top][All Lists]
Advanced

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

Re: redraw-current-line fails with multiline prompts


From: Chet Ramey
Subject: Re: redraw-current-line fails with multiline prompts
Date: Mon, 15 Feb 2016 16:21:45 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

On 2/15/16 3:57 PM, Hugh Davenport wrote:
> February 16 2016 9:11 AM, "Chet Ramey" <chet.ramey@case.edu> wrote:
>> On 2/12/16 12:45 AM, Hugh Davenport wrote:
>>
>>> Bash Version: 4.3
>>> Patch Level: 30
>>> Release Status: release
>>>
>>> Description:
>>> Assume I have a multiline prompt (`PS1="first\nsecond"`), and a bind to
>>> redraw-current-line (`bind '"\er": redraw-current-line'`). When I
>>> refresh the line with M-r, I get the following output:
>>> first
>>> first
>>> second
>>>
>>> What is happening is that the redraw-current-line is assuming that I
>>> only have a single line prompt, and is just redrawing that current
>>> line. Two possible solutions to this are:
>>> 1) Work out the last line of the prompt and only redraw that (makes
>>> sense with function name, or
>>> 2) Work out number of lines in the prompt, and redraw entire prompt.
>>>
>>> Repeat-By:
>>> Have a rc file with the following
>>> PS1="first\nsecond"
>>> bind '"\er": redraw-current-line'
>>>
>>> Then start bash with that rc file, and hit M-r a few times, notice that
>>> the last line gets overwritten, but the first line doesn't. You can
>>> expand this by having PS="first\nsecond\nthird" and seeing that the
>>> third line gets overwritten, but not the first and the second. This
>>> leads to a lot of wasted vertical space if you are redrawing often.
>>>
>>> Fix:
>>> I've got a patch for option 2, which works well with existing methods,
>>> but makes the function name a bit misleading.
>>
>> Thanks for the report. It's sufficient to change the call from
>> rl_forced_update_display to rl_redraw_prompt_last_line (your option 1).
>> This is what bash does for bash_execute_unix_command().
> 
> Hey Chet,
> 
> Thanks for your reply. OK, so my patch doesn't need that weird for loop.
> I couldn't find the redraw_prompt_last_line function when I had a quick
> search.

This is something that will be in bash-4.4/readline-7.0.  You can get the
current development sources to see how it will work.  According to my
change logs, it was added in November, 2014.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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