Use a deadline when eagerly processing notifications

pull/377/head
Blaž Hrastnik 3 years ago
parent 503ca112ae
commit f2d8ce3415

@ -159,9 +159,16 @@ impl Application {
} }
Some((id, call)) = self.editor.language_servers.incoming.next() => { Some((id, call)) = self.editor.language_servers.incoming.next() => {
self.handle_language_server_message(call, id).await; self.handle_language_server_message(call, id).await;
// eagerly process any other available notifications/calls // 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() { while let Some(Some((id, call))) = self.editor.language_servers.incoming.next().now_or_never() {
self.handle_language_server_message(call, id).await; 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(); self.render();
} }

Loading…
Cancel
Save