[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 15:10:10 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
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().
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/