Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirmation prompt: non-last line of multiline strings get printed twice #165

Open
grunweg opened this issue Jan 19, 2022 · 1 comment · May be fixed by #175
Open

Confirmation prompt: non-last line of multiline strings get printed twice #165

grunweg opened this issue Jan 19, 2022 · 1 comment · May be fixed by #175
Labels
c-interactions Context: Interactions t-bug Type: Bug fix z-all-prompts Tag: All prompts
Milestone

Comments

@grunweg
Copy link
Contributor

grunweg commented Jan 19, 2022

Thanks for this crate, by the way. I could insert a simple terminal prompt without knowing too much about terminals!

Steps to reproduce.
Take this small test programm.

[package]
name = "dialoguer-bug"
version = "0.1.0"
edition = "2021"
[dependencies]
dialoguer = "0.9.0"

$ cat src/main.rs
fn main() {
    let _ = dialoguer::Confirm::new().with_prompt("Prompt string with multiple lines:\nLine two?").interact().map_err(|e| e.to_string());
}
  1. Build and run the programm: cargo r
  2. A confirmation prompt appears:

Prompt string with multiple lines:
Line two?

  1. Answer either yes or no (doesn't matter which).
  2. My answer is displayed in the terminal.

Expected result The terminal output looks like this:

Prompt string with multiple lines:
Line two yes

Actual result The prompt is printed twice, resulting in output like this.

Prompt string with multiple lines:
Prompt string with multiple lines:
Line two yes

Meta. Tested on both version 0.9 and 0.8 of dialoguer.

@grunweg
Copy link
Contributor Author

grunweg commented Jan 19, 2022

I've played with this a bit and have a theory for the bug. I think the issue is that my prompt string has multiple lines: All lines but the first line get printed to the terminal. Taking a string with three lines results in the last two lines being printed twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-interactions Context: Interactions t-bug Type: Bug fix z-all-prompts Tag: All prompts
Projects
None yet
2 participants