Skip to content

Commit

Permalink
Restore the cursor after sigint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sigmaSd committed Mar 2, 2023
1 parent 88db691 commit 4131ec7
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 2 deletions.
93 changes: 91 additions & 2 deletions cargo-workspaces/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cargo-workspaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ lazy_static = "1.4.0"
indexmap = "1.6.0"
crates-index = "0.18.1"
dunce = "1.0.1"
ctrlc = "3.2.5"

[dev-dependencies]
assert_cmd = "1.0"
Expand Down
11 changes: 11 additions & 0 deletions cargo-workspaces/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ enum Cargo {
}

fn main() {
set_handlers();

let Cargo::Workspaces(opt) = Cargo::parse();

if opt.verbose {
Expand Down Expand Up @@ -87,3 +89,12 @@ fn main() {

finish(result)
}

fn set_handlers() {
// https://github.com/console-rs/dialoguer/issues/77
ctrlc::set_handler(move || {
let term = dialoguer::console::Term::stdout();
let _ = term.show_cursor();
})
.expect("Error setting Ctrl-C handler");
}

0 comments on commit 4131ec7

Please sign in to comment.