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.
This commit is contained in:
Clement Tsang 2025-04-10 19:53:55 -04:00 committed by GitHub
parent 69a4b59573
commit c68b190388
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<CrosstermBackend<std::io::Stdout>>, app_config_fields: &AppConfigFields,
terminal: &mut Terminal<CrosstermBackend<std::io::Stdout>>,
) -> 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(())
}