Skip to content

Commit

Permalink
fix: Handle signals before crossterm events (helix-editor#6170)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlexanderBrevig authored and wes-adams committed Jul 3, 2023
1 parent 0c2121d commit 5b6004e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions helix-term/src/application.rs
Expand Up @@ -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;
Expand Down

0 comments on commit 5b6004e

Please sign in to comment.