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

Cursor disappears when using SIGINT (ctrl-c). #77

Closed
mainrs opened this issue Aug 6, 2020 · 7 comments
Closed

Cursor disappears when using SIGINT (ctrl-c). #77

mainrs opened this issue Aug 6, 2020 · 7 comments

Comments

@mainrs
Copy link
Contributor

mainrs commented Aug 6, 2020

I use this crate over at https://github.com/SirWindfield/git-cm and a user opened an issue stating that after they press ctrl-c, their cursor disappears:

mainrs/git-cm#40

I think this is a bug/oversight inside of dialoguer or console and not my crate to be honest 🤔

@s2terminal
Copy link

I just have the same problem. This is reproduct code. (dialoguer = "0.6.2")

fn main() {
    if Confirm::new().with_prompt("Do you want to continue?").interact().unwrap() {
        println!("Looks like you want to continue");
    } else {
        println!("nevermind then :(");
    }
}

@jgilchrist
Copy link

jgilchrist commented Aug 6, 2020

@sirwindfield @s2terminal At the moment I'm working around this with a combination of the ctrlc and console crates:

ctrlc::set_handler(move || {
    let term = console::Term::stdout();
    let _ = term.show_cursor();
})?;

@pksunkara
Copy link
Collaborator

This is intentional. Ctrl-c and other stuff are not supposed to be handled by dialoguer when prompting.

@mainrs
Copy link
Contributor Author

mainrs commented Aug 15, 2020

Fair enough. I was pretty sure that dialoguer did actually use ctrl-c handling but after checking the crates it seems that I was wrong :)

I'll close this then.

@Ekleog
Copy link

Ekleog commented Apr 24, 2021

@sirwindfield Maybe it'd make sense to reopen this as a documentation issue to let people know of this limitation? IMO this should be documented in the front page of dialoguer. I recently hit it too with Ekleog/nixpkgs-check#20

@mainrs
Copy link
Contributor Author

mainrs commented Apr 24, 2021

No need to re-open. Documentation only changes are probably fine with a PR only :)

I mean technically this issue is resolved. But I do agree that a notice inside the docs/readme would be good!

sigmaSd added a commit to sigmaSd/cargo-workspaces that referenced this issue Mar 2, 2023
Currently if you hit ctrlc while using the interactive menu, the cursor
will not show up, the issue is not solved upstream console-rs/dialoguer#77
This is the available workaround
@chenyan2002
Copy link

This is intentional. Ctrl-c and other stuff are not supposed to be handled by dialoguer when prompting.

@pksunkara I understand dialoguer doesn't want to insert any signal handler. But would it be cleaner to intercept Ctrl+C here: https://github.com/console-rs/dialoguer/blob/master/src/prompts/select.rs#L236?

dialoguer sets term.hide_cursor() at the beginning, it makes sense to restore the cursor up on seeing ctrl+c.

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

No branches or pull requests

6 participants