on master help sign in
workspace symbols: Default to empty Vec on None

A language server might send None as the response to workspace symbols. We should treat this as the empty Vec rather than the server sending an error status. This fixes the interaction with gopls which uses None to mean no matching symbols.

commit2a60de74f9ccc935fa65031cfe30c62cf07bbbaf authorMichael Davis <mcarsondavis@gmail.com> dateThu 8 Dec 2022, 19:54 (4 years ago) parent35cf972
1 file changed+2−7
helix-term/src/commands/lsp.rs+2−7
helix-term/src/commands/lsp.rs+2−7
@@ -386,10 +386,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
386386 cx.callback(
387387 future,
388388 move |_editor, compositor, response: Option<Vec<lsp::SymbolInformation>>| {
389− let symbols = match response {
390− Some(s) => s,
391− None => return,
392− };
389+ let symbols = response.unwrap_or_default();
393390 let picker = sym_picker(symbols, current_url, offset_encoding);
394391 let get_symbols = |query: String, editor: &mut Editor| {
395392 let doc = doc!(editor);
@@ -420,9 +417,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
420417 let response: Option<Vec<lsp::SymbolInformation>> =
421418 serde_json::from_value(json)?;
422419
423− response.ok_or_else(|| {
424− anyhow::anyhow!("No response for workspace symbols from language server")
425− })
420+ Ok(response.unwrap_or_default())
426421 };
427422 future.boxed()
428423 };