dialoguer icon indicating copy to clipboard operation
dialoguer copied to clipboard

confirm: properly clear the terminal in case of a multi-line prompt string (take 2)

Open grunweg opened this issue 3 years ago • 5 comments

This a revised version of #166, see discussion there. Fixes #165.

grunweg avatar Feb 14 '22 18:02 grunweg

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() (not TermThemeRenderer::clear()) --- hence didn't notice
  • the input prompt calls clear_line() right before calling clear() :-)
  • 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_string to render the prompt are input, password and confirm. All other prompts either use write_formatted_line, or write_formatted_prompt which calls write_formatted_line: both add a newline after the text that was written.

grunweg avatar May 06 '22 08:05 grunweg

the input prompt calls clear_line() right before calling clear() :-)

I just pushed an additional commit which removes these now-superfluous calls.

grunweg avatar May 06 '22 08:05 grunweg