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

Inquire forgets to add newlines in 0.7.1 #233

Closed
msrd0 opened this issue Mar 12, 2024 · 5 comments · Fixed by #234
Closed

Inquire forgets to add newlines in 0.7.1 #233

msrd0 opened this issue Mar 12, 2024 · 5 comments · Fixed by #234

Comments

@msrd0
Copy link

msrd0 commented Mar 12, 2024

Describe the bug

I just upgraded from 0.6.2 to 0.7.1. Suddenly, all prompts overwrite the previous prompt, as if there is a newline missing.

To Reproduce
Steps to reproduce the behavior:

  1. Add inquire dependency 0.7 with default features
  2. Call CustomType::...::prompt()
  3. Answer the prompt
  4. Call another prompt
  5. See error

Expected behavior
I expect a newline to be added to the previous prompt, so that the next prompt does not overwrite the previous one.

Desktop (please complete the following information):

  • OS: ArchLinux
  • Browser Terminal: alacritty
  • Version: 0.7.1 (0.7 is broken as well)
@mikaelmello
Copy link
Owner

Hey, I haven't been able to reproduce the issue, can you give me more details? Maybe a repo that reproes the issue

This may be limtied to Alacritty, but unfortunately I can't try alacritty right now as it seems the Mac installer has some issues, but my tests have been fine on both Mac and Ubuntu (via SSH) systems.

@Sydonian
Copy link

Sydonian commented Mar 16, 2024

I encountered the same problem, and below are my test codes:

use inquire::Text;

fn main() {
    loop {
        match Text::new(">>").prompt() {
            Ok(text) => println!("{}", text),
            Err(e) => println!("Error: {}", e),
        }
    }
}

I noticed that if I run the program and just press enter key about 12 times, then it will lose the newline after the echo of my input:

20240316165819

I'm using Windows 11, and I have tried it on PowerShell and CMD, but both appear the same problem and even the CMD only need 11 enter keys.

@mikaelmello
Copy link
Owner

Thanks @Sydonian, I was able to reproduce the issue after the "press enter until it happens" advice.

No idea how this even works half the time, but from my tests when it reached the "broken state" it stayed like that.

Looks like the issue is because the new rendering logic ignores empty lines.

Can you pleae test the fix?

[dependencies]
inquire = { git = "https://github.com/mikaelmello/inquire.git", branch = "mm/fix-new-line-prompt-end" }

@Sydonian
Copy link

Thanks @Sydonian, I was able to reproduce the issue after the "press enter until it happens" advice.

No idea how this even works half the time, but from my tests when it reached the "broken state" it stayed like that.

Looks like the issue is because the new rendering logic ignores empty lines.

Can you pleae test the fix?

[dependencies]
inquire = { git = "https://github.com/mikaelmello/inquire.git", branch = "mm/fix-new-line-prompt-end" }

I tried this on the test program and my project, both work fine, thank you!

@msrd0
Copy link
Author

msrd0 commented Mar 17, 2024

Can also confirm the branch works. I always accepted the default value for the first prompt, so the bug always triggered for me.

mikaelmello added a commit that referenced this issue Mar 17, 2024
mikaelmello added a commit that referenced this issue Mar 17, 2024
* Fix missing newlines at end of prompts

Fixes #233

* Fix changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants