dialoguer
dialoguer copied to clipboard
confirm: properly clear the terminal in case of a multi-line prompt string (take 2)
This a revised version of #166, see discussion there. Fixes #165.
I just squashed changes and reworded the commit message. Basically, I think this fixes two bugs/defects:
- the confirmation prompt should clear the entire rendering, not just the current line
TermThemeRenderer::clear()should always clear the current line: currently, anything on the current line is left behind. In my opinion, that's simply an oversight.
Why did none of the other prompts notice this before?
- the confirmation prompt was calling
term.clear_line()(notTermThemeRenderer::clear()) --- hence didn't notice - the input prompt calls
clear_line()right before callingclear():-) - the password prompt asks for input, which is ended by a newline --> there is automatically a line break, and the new line is empty
- the only prompts using
TermThemeRenderer::write_formatted_stringto render the prompt are input, password and confirm. All other prompts either usewrite_formatted_line, orwrite_formatted_promptwhich callswrite_formatted_line: both add a newline after the text that was written.
the input prompt calls clear_line() right before calling clear() :-)
I just pushed an additional commit which removes these now-superfluous calls.