helix
helix copied to clipboard
Respect SIG_IGN for SIGTSTP
This implementation is probably ugly.
Any pointers to make it cleaner is much appreciated!
It works, tested with elvish, bash, zsh and sh. It correctly disables C-z for elvish but not the others.
Fixes #3321
Ready for your wise eyes again @the-mikedavis (tests and lints pass now)
Looking at this now, I think an AtomicBool would be simpler than a OnceCell. You can use Ordering::Relaxed everywhere since we don't care about race conditions of changes between threads.
The alternative way to do this without using shared memory would be to pass whether or not suspension is allowed through from Application to helix_view::editor::Editor. That might be even cleaner. Then you would check in suspend
if cx.editor.a_new_field_that_says_whether_or_not_we_can_suspend {
// send SIG_TSTP
}
Oh actually, since Editor is created before the Application, you can figure out whether sigtstp is enabled higher up in Application::new before Editor::new is called and pass the bool to Editor::new. No need to use an AtomicBool with this approach, you can just put a new pub suspend_enabled: bool on the helix_view::editor::Editor type.
Thanks for all the amazing feedback @the-mikedavis! I think all of them are in now.
Looking forward to hopefully get this merged so I can get back to master :)
@AlexanderBrevig It looks like there may need to be some conditional compilation. I don't think Windows has typical signals.
Alright, one last nit from me 😅
In some places we have enable_suspend and in other suspend_enabled. Since there isn't anything to do in order to enable suspending I think we should just use suspend_enabled
Alright, one last nit from me sweat_smile
In some places we have
enable_suspendand in othersuspend_enabled. Since there isn't anything to do in order to enable suspending I think we should just usesuspend_enabled
I love your feedback and nits :) Absolutely prefer that name myself, I think it's a remnant from the private AtomicBool with get/set-like public API.
It's all much cleaner now, thanks to you 👍🏻