Skip to content

Commit

Permalink
fixed ctrlc handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 1, 2024
1 parent 9ab7159 commit 9bbd7ba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl Run {
for name in tasks.keys() {
s = s.option(DemandOption::new(name));
}
let _ = ctrlc::handle_ctrlc()?;
let _ctrlc = ctrlc::handle_ctrlc()?;
let name = s.run()?;
match tasks.get(name) {
Some(task) => Ok((*task).clone()),
Expand Down
2 changes: 1 addition & 1 deletion src/cli/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Upgrade {
}

fn get_interactive_tool_set(&self, outdated: &OutputVec) -> Result<HashSet<ToolVersion>> {
let _ = ui::ctrlc::handle_ctrlc()?;
let _ctrlc = ui::ctrlc::handle_ctrlc()?;
let mut ms = demand::MultiSelect::new("mise upgrade")
.description("Select tools to upgrade")
.filterable(true)
Expand Down
7 changes: 3 additions & 4 deletions src/ui/progress_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ pub struct ProgressReport {
pub pb: ProgressBar,
prefix: String,
pad: usize,
#[allow(dead_code)]
handle: Option<ui::ctrlc::HandleGuard>,
_handle: Option<ui::ctrlc::HandleGuard>,
}

static LONGEST_PLUGIN_NAME: Lazy<usize> = Lazy::new(|| {
Expand Down Expand Up @@ -58,7 +57,7 @@ fn success_prefix(pad: usize, prefix: &str) -> String {

impl ProgressReport {
pub fn new(prefix: String) -> ProgressReport {
let handle = ui::ctrlc::handle_ctrlc().unwrap_or_default();
let _handle = ui::ctrlc::handle_ctrlc().unwrap_or_default();
let pad = *LONGEST_PLUGIN_NAME;
let pb = ProgressBar::new(100)
.with_style(PROG_TEMPLATE.clone())
Expand All @@ -68,7 +67,7 @@ impl ProgressReport {
prefix,
pb,
pad,
handle,
_handle,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static MUTEX: Mutex<()> = Mutex::new(());

pub fn confirm<S: Into<String>>(message: S) -> eyre::Result<bool> {
let _lock = MUTEX.lock().unwrap(); // Prevent multiple prompts at once
let _ = ctrlc::handle_ctrlc()?;
let _handle = ctrlc::handle_ctrlc()?;

if !console::user_attended_stderr() {
return Ok(false);
Expand Down

0 comments on commit 9bbd7ba

Please sign in to comment.