on master help sign in
Use StreamExt::select_next_some to avoid infinitely spinning on empty stream.
commitebfd67ac6ab0e0b10b99dec2d5fc7bb42d8fb10b authorBlaž Hrastnik <blaz@mxxn.io> dateTue 30 Mar 2021, 16:39 (6 years ago) parente833d65
1 file changed+7−10
helix-term/src/application.rs+7−10
helix-term/src/application.rs+7−10
@@ -99,10 +99,10 @@ impl Application {
9999 event = reader.next().fuse() => {
100100 self.handle_terminal_events(event)
101101 }
102− call = self.editor.language_servers.incoming.next().fuse() => {
102+ call = futures_util::StreamExt::select_next_some(&mut self.editor.language_servers.incoming) => {
103103 self.handle_language_server_message(call).await
104104 }
105− callback = self.callbacks.next().fuse() => {
105+ callback = futures_util::StreamExt::select_next_some(&mut self.callbacks) => {
106106 self.handle_language_server_callback(callback)
107107 }
108108 }
@@ -110,9 +110,9 @@ impl Application {
110110 }
111111 pub fn handle_language_server_callback(
112112 &mut self,
113− callback: Option<Result<LspCallbackWrapper, anyhow::Error>>,
113+ callback: Result<LspCallbackWrapper, anyhow::Error>,
114114 ) {
115− if let Some(Ok(callback)) = callback {
115+ if let Ok(callback) = callback {
116116 // TODO: handle Err()
117117 callback(&mut self.editor, &mut self.compositor);
118118 self.render();
@@ -144,12 +144,10 @@ impl Application {
144144 }
145145 }
146146
147− pub async fn handle_language_server_message(&mut self, call: Option<helix_lsp::Call>) {
147+ pub async fn handle_language_server_message(&mut self, call: helix_lsp::Call) {
148148 use helix_lsp::{Call, Notification};
149149 match call {
150− Some(Call::Notification(helix_lsp::jsonrpc::Notification {
151− method, params, ..
152− })) => {
150+ Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => {
153151 let notification = Notification::parse(&method, params);
154152 match notification {
155153 Notification::PublishDiagnostics(params) => {
@@ -203,7 +201,7 @@ impl Application {
203201 _ => unreachable!(),
204202 }
205203 }
206− Some(Call::MethodCall(call)) => {
204+ Call::MethodCall(call) => {
207205 error!("Method not found {}", call.method);
208206
209207 // self.language_server.reply(
@@ -216,7 +214,6 @@ impl Application {
216214 // }),
217215 // );
218216 }
219− None => (),
220217 e => unreachable!("{:?}", e),
221218 }
222219 }