fix: Handle signals before crossterm events (#6170)

This is a workaround for a freeze when suspending Helix with C-z on
non-Windows systems. The check for the keyboard enhancement protocol
locks up crossterm's internal event reading/polling system by trying to
set up multiple concurrent readers. `input_stream.next()` sets up one
reader looking for regular crossterm events while the
`supports_keyboard_enhancement` query sets up another looking for
internal events. The latter hangs for two seconds or until the former
yields an event. By handling signals first we don't lock up the mutex
by trying to read keyboard events.
This commit is contained in:
Alexander Brevig 2023-03-05 02:52:20 +01:00 committed by GitHub
parent bf872366fd
commit a2e54167d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -345,12 +345,12 @@ impl Application {
tokio::select! {
biased;
Some(event) = input_stream.next() => {
self.handle_terminal_events(event).await;
}
Some(signal) = self.signals.next() => {
self.handle_signals(signal).await;
}
Some(event) = input_stream.next() => {
self.handle_terminal_events(event).await;
}
Some(callback) = self.jobs.futures.next() => {
self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
self.render().await;