lsp: Eagerly process notifications/server calls to avoid re-rendering

imgbot
Blaž Hrastnik 4 years ago
parent 6dddd5cd1d
commit 2f321b9335

@ -152,14 +152,19 @@ impl Application {
break; break;
} }
use futures_util::StreamExt; use futures_util::{FutureExt, StreamExt};
tokio::select! { tokio::select! {
event = reader.next() => { event = reader.next() => {
self.handle_terminal_events(event) self.handle_terminal_events(event)
} }
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
while let Some(Some((id, call))) = self.editor.language_servers.incoming.next().now_or_never() {
self.handle_language_server_message(call, id).await;
}
self.render();
} }
Some(callback) = &mut self.callbacks.next() => { Some(callback) = &mut self.callbacks.next() => {
self.handle_language_server_callback(callback) self.handle_language_server_callback(callback)
@ -294,7 +299,6 @@ impl Application {
doc.set_diagnostics(diagnostics); doc.set_diagnostics(diagnostics);
// TODO: we want to process all the events in queue, then render. publishDiagnostic tends to send a whole bunch of events // TODO: we want to process all the events in queue, then render. publishDiagnostic tends to send a whole bunch of events
self.render();
} }
} }
Notification::ShowMessage(params) => { Notification::ShowMessage(params) => {
@ -330,7 +334,6 @@ impl Application {
self.editor.clear_status(); self.editor.clear_status();
// we want to render to clear any leftover spinners or messages // we want to render to clear any leftover spinners or messages
self.render();
return; return;
} }
} }
@ -378,7 +381,6 @@ impl Application {
if self.config.lsp.display_messages { if self.config.lsp.display_messages {
self.editor.set_status(status); self.editor.set_status(status);
} }
self.render();
} }
_ => unreachable!(), _ => unreachable!(),
} }

Loading…
Cancel
Save