diff options
author | Blaž Hrastnik | 2021-03-30 07:39:24 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-30 07:39:24 +0000 |
commit | ebfd67ac6ab0e0b10b99dec2d5fc7bb42d8fb10b (patch) | |
tree | c5d6774bdbbc3181100da8712f29d1b306aac56c /helix-term | |
parent | e833d65b77211c76cd1eef1ac723efb3f61d38ba (diff) |
Use StreamExt::select_next_some to avoid infinitely spinning on empty stream.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/application.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index b7f88aaa..2a813081 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -99,10 +99,10 @@ impl Application { event = reader.next().fuse() => { self.handle_terminal_events(event) } - call = self.editor.language_servers.incoming.next().fuse() => { + call = futures_util::StreamExt::select_next_some(&mut self.editor.language_servers.incoming) => { self.handle_language_server_message(call).await } - callback = self.callbacks.next().fuse() => { + callback = futures_util::StreamExt::select_next_some(&mut self.callbacks) => { self.handle_language_server_callback(callback) } } @@ -110,9 +110,9 @@ impl Application { } pub fn handle_language_server_callback( &mut self, - callback: Option<Result<LspCallbackWrapper, anyhow::Error>>, + callback: Result<LspCallbackWrapper, anyhow::Error>, ) { - if let Some(Ok(callback)) = callback { + if let Ok(callback) = callback { // TODO: handle Err() callback(&mut self.editor, &mut self.compositor); self.render(); @@ -144,12 +144,10 @@ impl Application { } } - pub async fn handle_language_server_message(&mut self, call: Option<helix_lsp::Call>) { + pub async fn handle_language_server_message(&mut self, call: helix_lsp::Call) { use helix_lsp::{Call, Notification}; match call { - Some(Call::Notification(helix_lsp::jsonrpc::Notification { - method, params, .. - })) => { + Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => { let notification = Notification::parse(&method, params); match notification { Notification::PublishDiagnostics(params) => { @@ -203,7 +201,7 @@ impl Application { _ => unreachable!(), } } - Some(Call::MethodCall(call)) => { + Call::MethodCall(call) => { error!("Method not found {}", call.method); // self.language_server.reply( @@ -216,7 +214,6 @@ impl Application { // }), // ); } - None => (), e => unreachable!("{:?}", e), } } |