aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Davis2022-12-09 01:54:15 +0000
committerBlaž Hrastnik2022-12-15 08:52:44 +0000
commit2a60de74f9ccc935fa65031cfe30c62cf07bbbaf (patch)
treeab2f0100d35158d7e12044882ada9098761a1a73
parent35cf972ce459eda6ceffb7a7c256a4bc9f4e6e39 (diff)
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.
-rw-r--r--helix-term/src/commands/lsp.rs9
1 files changed, 2 insertions, 7 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 8052dcac..86b0c5fa 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -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);
@@ -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()
};