Skip to content

Commit

Permalink
workspace symbols: Default to empty Vec on None
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis authored and archseer committed Dec 15, 2022
1 parent 35cf972 commit 2a60de7
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
cx.callback(
future,
move |_editor, compositor, response: Option<Vec<lsp::SymbolInformation>>| {
let symbols = match response {
Some(s) => s,
None => return,
};
let symbols = response.unwrap_or_default();
let picker = sym_picker(symbols, current_url, offset_encoding);
let get_symbols = |query: String, editor: &mut Editor| {
let doc = doc!(editor);
Expand Down Expand Up @@ -420,9 +417,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
let response: Option<Vec<lsp::SymbolInformation>> =
serde_json::from_value(json)?;

response.ok_or_else(|| {
anyhow::anyhow!("No response for workspace symbols from language server")
})
Ok(response.unwrap_or_default())
};
future.boxed()
};
Expand Down

0 comments on commit 2a60de7

Please sign in to comment.