on master help sign in
workspace symbols: Default to empty Vec on None
2a60de7Michael Davis
helix-term/src/commands/lsp.rs+2−7
@@ -386,10 +386,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
386 cx.callback(
386 cx.callback(
387 future,
387 future,
388 move |_editor, compositor, response: Option<Vec<lsp::SymbolInformation>>| {
388 move |_editor, compositor, response: Option<Vec<lsp::SymbolInformation>>| {
389− let symbols = match response {
389+ let symbols = response.unwrap_or_default();
390− Some(s) => s,
391− None => return,
392− };
393 let picker = sym_picker(symbols, current_url, offset_encoding);
390 let picker = sym_picker(symbols, current_url, offset_encoding);
394 let get_symbols = |query: String, editor: &mut Editor| {
391 let get_symbols = |query: String, editor: &mut Editor| {
395 let doc = doc!(editor);
392 let doc = doc!(editor);
@@ -420,9 +417,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
420 let response: Option<Vec<lsp::SymbolInformation>> =
417 let response: Option<Vec<lsp::SymbolInformation>> =
421 serde_json::from_value(json)?;
418 serde_json::from_value(json)?;
422
419
423− response.ok_or_else(|| {
420+ Ok(response.unwrap_or_default())
424− anyhow::anyhow!("No response for workspace symbols from language server")
425− })
426 };
421 };
427 future.boxed()
422 future.boxed()
428 };
423 };