Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ctrl-c to quit the app #297

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

bloznelis
Copy link

Resolves #258.

Firstly, thanks for this - I love magit and command line, so this feels like a perfect tool for me. As a thank you, I figured I will contribute a small ticket for you.

Now ctrl-c will exit the app bypassing any default or custom bindings. If you want to tweak the logic (for example exit only when the amount of screens is 1 i.e. root-level) - add more conditions to is_system_quit function.

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.41%. Comparing base (0f02879) to head (a45e9fc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #297      +/-   ##
==========================================
+ Coverage   88.40%   88.41%   +0.01%     
==========================================
  Files          62       62              
  Lines        5578     5583       +5     
==========================================
+ Hits         4931     4936       +5     
  Misses        647      647              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@altsem
Copy link
Owner

altsem commented Dec 26, 2024

Hi! This is great :)

I wonder if someone would ever want this to be configurable. 🤔

Perhaps it wouldn't hurt, what do you think?

In the case, I believe there's a module "config.rs", as well as a "default_config.toml", where other stuff is configured.

Currently on vacation so could include it in a release when I'm back home (February).

@bloznelis
Copy link
Author

bloznelis commented Dec 30, 2024

I wonder if someone would ever want this to be configurable. 🤔

Unlikely (?).

Now that I gave this a second though, I think that the initial implementation I made is a bit naive. It wouldn't work if for some reason update hangs/takes too long and the user wants to kill the app, because it would need to wait for previous step to finish before handling the ctrl-c.

A better way would be to react on signals. So in the case of SIGINT (produced by ctrl-c), we would interrupt and close the app without waiting for update to resolve.

@bloznelis
Copy link
Author

bloznelis commented Dec 30, 2024

Probably should happen somewhere around here. If we receive the SIGINT we break the while loop.

@altsem
Copy link
Owner

altsem commented Dec 30, 2024

Yea that'd make sense :)

If there's a pending external command running, perhaps the signal should be propagated to it.

I can't recall if Ctrl-C produces a signal when terminal raw-mode is enabled, might be a gotcha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<ctrl+c> to exit the application
2 participants