on master help sign in
Remove some of the panics, just log instead.
caf4349Blaž Hrastnik
helix-lsp/src/lib.rs+9−4
@@ -130,10 +130,10 @@ pub enum Notification {
130}
130}
131
131
132impl Notification {
132impl Notification {
133− pub fn parse(method: &str, params: jsonrpc::Params) -> Notification {
133+ pub fn parse(method: &str, params: jsonrpc::Params) -> Option<Notification> {
134 use lsp::notification::Notification as _;
134 use lsp::notification::Notification as _;
135
135
136− match method {
136+ let notification = match method {
137 lsp::notification::PublishDiagnostics::METHOD => {
137 lsp::notification::PublishDiagnostics::METHOD => {
138 let params: lsp::PublishDiagnosticsParams = params
138 let params: lsp::PublishDiagnosticsParams = params
139 .parse()
139 .parse()
@@ -155,8 +155,13 @@ impl Notification {
155
155
156 Notification::LogMessage(params)
156 Notification::LogMessage(params)
157 }
157 }
158+ _ => {
158− _ => unimplemented!("unhandled notification: {}", method),
159+ log::error!("unhandled LSP notification: {}", method);
160+ return None;
161+ }
159− }
162+ };
163+
164+ Some(notification)
160 }
165 }
161}
166}
162
167
helix-term/src/application.rs+5−1
@@ -145,7 +145,11 @@ impl Application {
145 use helix_lsp::{Call, Notification};
145 use helix_lsp::{Call, Notification};
146 match call {
146 match call {
147 Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => {
147 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+
149 // TODO: parse should return Result/Option
153 // TODO: parse should return Result/Option
150 match notification {
154 match notification {
151 Notification::PublishDiagnostics(params) => {
155 Notification::PublishDiagnostics(params) => {
helix-term/src/commands.rs+6−3
@@ -1883,7 +1883,8 @@ pub fn format_selections(cx: &mut Context) {
1883 };
1883 };
1884 // TODO: handle fails
1884 // TODO: handle fails
1885 // TODO: concurrent map
1885 // TODO: concurrent map
1886+
1886− unimplemented!(); // neeed to block to get the formatting
1887+ // TODO: need to block to get the formatting
1887
1888
1888 // let edits = block_on(language_server.text_document_range_formatting(
1889 // let edits = block_on(language_server.text_document_range_formatting(
1889 // doc.identifier(),
1890 // doc.identifier(),
@@ -2098,10 +2099,12 @@ pub fn hover(cx: &mut Context) {
2098 lsp::HoverContents::Scalar(contents) => {
2099 lsp::HoverContents::Scalar(contents) => {
2099 // markedstring(string/languagestring to be highlighted)
2100 // markedstring(string/languagestring to be highlighted)
2100 // TODO
2101 // TODO
2101− unimplemented!("{:?}", contents)
2102+ log::error!("hover contents {:?}", contents);
2103+ return;
2102 }
2104 }
2103 lsp::HoverContents::Array(contents) => {
2105 lsp::HoverContents::Array(contents) => {
2104− unimplemented!("{:?}", contents)
2106+ log::error!("hover contents {:?}", contents);
2107+ return;
2105 }
2108 }
2106 // TODO: render markdown
2109 // TODO: render markdown
2107 lsp::HoverContents::Markup(contents) => contents.value,
2110 lsp::HoverContents::Markup(contents) => contents.value,