Skip to content

Make newlines in prompt display correctly

Michael Aaron Murphy requested to merge covercash2:master into master

Created by: covercash2

Problem:

Prompts containing newlines were not printing properly. The last line would print at the column of the line above it, and any lines before the last would be repeated with every keystroke.

liner runs the function for the prompt every keystroke and erases only the last line from the prompt function it's given. This leads to many trailing prompts and odd behavior in the formatting.

Solution: My solution was to remove the top lines from the prompt and present them as prompt_info, semantically. Then liner can print the last line of the prompt as much as it wants to.

If the prompt contains a newline the lines are printed to stdout, and the last line is supplied to the liner library as a prompt.

Drawbacks:

I'm new to the project and not sure if I handled the stdout correctly - I could use some guidance there, maybe.

I know we're all speed freaks, but I couldn't help but do a String allocation. It's only once per command, though.

Fixes:

I couldn't find an issue for this. It's my first go at coding on this project, so this is just getting my feet wet.

** Other **

Let me know what else I can do. I'm still reading through the source code.

Merge request reports