From c68b1903884000146fd6c4a031282c779b498893 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Thu, 10 Apr 2025 19:53:55 -0400 Subject: [PATCH] bug: fix incorrect disable mouse click condition on cleanup (#1713) Looks like a bug slipped through in #1706 so when stopping the program click events would continue. I could just fix the condition but I think it's fine to just unconditionally disable click events on cleanup. --- src/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 24f11a35..5586c27c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,7 +62,7 @@ fn try_drawing( painter: &mut canvas::Painter, ) -> anyhow::Result<()> { if let Err(err) = painter.draw_data(terminal, app) { - cleanup_terminal(terminal, &app.app_config_fields)?; + cleanup_terminal(terminal)?; Err(err.into()) } else { Ok(()) @@ -71,14 +71,13 @@ fn try_drawing( /// Clean up the terminal before returning it to the user. fn cleanup_terminal( - terminal: &mut Terminal>, app_config_fields: &AppConfigFields, + terminal: &mut Terminal>, ) -> anyhow::Result<()> { disable_raw_mode()?; - if app_config_fields.disable_click { - execute!(terminal.backend_mut(), DisableMouseCapture)?; - } + execute!( terminal.backend_mut(), + DisableMouseCapture, DisableBracketedPaste, LeaveAlternateScreen, Show, @@ -457,7 +456,7 @@ pub fn start_bottom(enable_error_hook: &mut bool) -> anyhow::Result<()> { // I think doing it in this order is safe... // TODO: maybe move the cancellation token to the ctrl-c handler? cancellation_token.cancel(); - cleanup_terminal(&mut terminal, &app.app_config_fields)?; + cleanup_terminal(&mut terminal)?; Ok(()) }