From f2d8ce3415fa2dcc6be283415c42219fd399adb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 25 Jun 2021 13:22:50 +0900 Subject: [PATCH] Use a deadline when eagerly processing notifications --- helix-term/src/application.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index f33a58316..aea0d89fe 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -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(); }