console-rs / dialoguer

Rust utility library for nice command line prompts and similar things
MIT License
1.33k stars 142 forks source link

Unable to change selection of a Select in certain terminals. #271

Open simon-wh opened 1 year ago

simon-wh commented 1 year ago

I have a bit of a weird issue that I'm not sure how to approach. I started using dialoguer for some simple CLI Selects for a small CLI tool. The code I use is very close to the examples:

  let choice = Select::with_theme(&ColorfulTheme::default())
                .with_prompt("Pick a device, any device")
                .default(0)
                .items(devices.iter().as_slice())
                .interact_opt()
                .unwrap();

However, it works as expected in some terminals and not others. When it doesn't work, I'll try and navigate, the prompt flickers (indicating a re-render) but the selection doesn't actually change.

What works:

What doesn't work:

It failing on VSCode for Web would kinda be fair enough, as it's not your standard terminal set-up. But I was quite confused why iTerm2 wasn't working properly

It's a little bit annoying as it means I have to have an additional terminal open on the side just for running certain commands.

Any assistance on this would be appreciated

Aside: I switched to dialoguer from youchoose to improve Windows compatibility for my tool. For what it's worth, I never had this issue with it