Skip to content

Commit

Permalink
Use a deadline when eagerly processing notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jun 25, 2021
1 parent 503ca11 commit f2d8ce3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,16 @@ impl Application {
}
Some((id, call)) = self.editor.language_servers.incoming.next() => {
self.handle_language_server_message(call, id).await;

// eagerly process any other available notifications/calls
let now = std::time::Instant::now();
let deadline = std::time::Duration::from_millis(10);
while let Some(Some((id, call))) = self.editor.language_servers.incoming.next().now_or_never() {
self.handle_language_server_message(call, id).await;

if now.elapsed() > deadline { // use a deadline so we don't block too long
break;
}
}
self.render();
}
Expand Down

0 comments on commit f2d8ce3

Please sign in to comment.