February 16 2016 9:11 AM, "Chet Ramey" <chet.ra...@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. Would that change be something that you would do to replace the readline function binding redraw_current_line, or would it be something else that would be exposed? It would be great if there was a way to redraw the prompt without it generating a lot of extra vertical lines. Cheers, Hugh > > Chet > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet