diff --git a/crates/uv-requirements/src/confirm.rs b/crates/uv-requirements/src/confirm.rs index 3b111d331764..7eb7d8b5932a 100644 --- a/crates/uv-requirements/src/confirm.rs +++ b/crates/uv-requirements/src/confirm.rs @@ -6,7 +6,8 @@ use console::{style, Key, Term}; /// This is a slimmed-down version of `dialoguer::Confirm`, with the post-confirmation report /// enabled. pub(crate) fn confirm(message: &str, term: &Term, default: bool) -> Result { - ctrlc::set_handler(move || { + // Set the Ctrl-C handler to exit the process. + let result = ctrlc::set_handler(move || { let term = Term::stderr(); term.show_cursor().ok(); term.flush().ok(); @@ -17,7 +18,16 @@ pub(crate) fn confirm(message: &str, term: &Term, default: bool) -> Result } else { 130 }); - })?; + }); + + match result { + Ok(()) => {} + Err(ctrlc::Error::MultipleHandlers) => { + // If multiple handlers were set, we assume that the existing handler is our + // confirmation handler, and continue. + } + Err(e) => return Err(e.into()), + } let prompt = format!( "{} {} {} {} {}",