From caf434992563cbdedeccb5574af16091e987f365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sat, 8 May 2021 18:17:13 +0900 Subject: [PATCH] Remove some of the panics, just log instead. --- helix-lsp/src/lib.rs | 13 +++++++++---- helix-term/src/application.rs | 6 +++++- helix-term/src/commands.rs | 9 ++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 6adaa3f87..1bab2a173 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -130,10 +130,10 @@ pub enum Notification { } impl Notification { - pub fn parse(method: &str, params: jsonrpc::Params) -> Notification { + pub fn parse(method: &str, params: jsonrpc::Params) -> Option { use lsp::notification::Notification as _; - match method { + let notification = match method { lsp::notification::PublishDiagnostics::METHOD => { let params: lsp::PublishDiagnosticsParams = params .parse() @@ -155,8 +155,13 @@ impl Notification { Notification::LogMessage(params) } - _ => unimplemented!("unhandled notification: {}", method), - } + _ => { + log::error!("unhandled LSP notification: {}", method); + return None; + } + }; + + Some(notification) } } diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index ae7e22bd8..42a46f1e7 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -145,7 +145,11 @@ impl Application { use helix_lsp::{Call, Notification}; match call { Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => { - let notification = Notification::parse(&method, params); + let notification = match Notification::parse(&method, params) { + Some(notification) => notification, + None => return, + }; + // TODO: parse should return Result/Option match notification { Notification::PublishDiagnostics(params) => { diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 959bd7d5f..594256708 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1883,7 +1883,8 @@ pub fn format_selections(cx: &mut Context) { }; // TODO: handle fails // TODO: concurrent map - unimplemented!(); // neeed to block to get the formatting + + // TODO: need to block to get the formatting // let edits = block_on(language_server.text_document_range_formatting( // doc.identifier(), @@ -2098,10 +2099,12 @@ pub fn hover(cx: &mut Context) { lsp::HoverContents::Scalar(contents) => { // markedstring(string/languagestring to be highlighted) // TODO - unimplemented!("{:?}", contents) + log::error!("hover contents {:?}", contents); + return; } lsp::HoverContents::Array(contents) => { - unimplemented!("{:?}", contents) + log::error!("hover contents {:?}", contents); + return; } // TODO: render markdown lsp::HoverContents::Markup(contents) => contents.value,