on master help sign in
Remove some of the panics, just log instead.
commitcaf434992563cbdedeccb5574af16091e987f365 authorBlaž Hrastnik <blaz@mxxn.io> dateSat 8 May 2021, 18:17 (5 years ago) parentd24844b
3 files changed+20−8
helix-lsp/src/lib.rs+9−4 helix-term/src/application.rs+5−1 helix-term/src/commands.rs+6−3
helix-lsp/src/lib.rs+9−4
@@ -130,10 +130,10 @@ pub enum Notification {
130130}
131131
132132impl Notification {
133− pub fn parse(method: &str, params: jsonrpc::Params) -> Notification {
133+ pub fn parse(method: &str, params: jsonrpc::Params) -> Option<Notification> {
134134 use lsp::notification::Notification as _;
135135
136− match method {
136+ let notification = match method {
137137 lsp::notification::PublishDiagnostics::METHOD => {
138138 let params: lsp::PublishDiagnosticsParams = params
139139 .parse()
@@ -155,8 +155,13 @@ impl Notification {
155155
156156 Notification::LogMessage(params)
157157 }
158− _ => unimplemented!("unhandled notification: {}", method),
159− }
158+ _ => {
159+ log::error!("unhandled LSP notification: {}", method);
160+ return None;
161+ }
162+ };
163+
164+ Some(notification)
160165 }
161166}
162167
helix-term/src/application.rs+5−1
@@ -145,7 +145,11 @@ impl Application {
145145 use helix_lsp::{Call, Notification};
146146 match call {
147147 Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => {
148− let notification = Notification::parse(&method, params);
148+ let notification = match Notification::parse(&method, params) {
149+ Some(notification) => notification,
150+ None => return,
151+ };
152+
149153 // TODO: parse should return Result/Option
150154 match notification {
151155 Notification::PublishDiagnostics(params) => {
helix-term/src/commands.rs+6−3
@@ -1883,7 +1883,8 @@ pub fn format_selections(cx: &mut Context) {
18831883 };
18841884 // TODO: handle fails
18851885 // TODO: concurrent map
1886− unimplemented!(); // neeed to block to get the formatting
1886+
1887+ // TODO: need to block to get the formatting
18871888
18881889 // let edits = block_on(language_server.text_document_range_formatting(
18891890 // doc.identifier(),
@@ -2098,10 +2099,12 @@ pub fn hover(cx: &mut Context) {
20982099 lsp::HoverContents::Scalar(contents) => {
20992100 // markedstring(string/languagestring to be highlighted)
21002101 // TODO
2101− unimplemented!("{:?}", contents)
2102+ log::error!("hover contents {:?}", contents);
2103+ return;
21022104 }
21032105 lsp::HoverContents::Array(contents) => {
2104− unimplemented!("{:?}", contents)
2106+ log::error!("hover contents {:?}", contents);
2107+ return;
21052108 }
21062109 // TODO: render markdown
21072110 lsp::HoverContents::Markup(contents) => contents.value,