mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-10 10:35:16 +03:00
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.
This commit is contained in:
parent
35cf972ce4
commit
2a60de74f9
@ -386,10 +386,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
|
|||||||
cx.callback(
|
cx.callback(
|
||||||
future,
|
future,
|
||||||
move |_editor, compositor, response: Option<Vec<lsp::SymbolInformation>>| {
|
move |_editor, compositor, response: Option<Vec<lsp::SymbolInformation>>| {
|
||||||
let symbols = match response {
|
let symbols = response.unwrap_or_default();
|
||||||
Some(s) => s,
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
let picker = sym_picker(symbols, current_url, offset_encoding);
|
let picker = sym_picker(symbols, current_url, offset_encoding);
|
||||||
let get_symbols = |query: String, editor: &mut Editor| {
|
let get_symbols = |query: String, editor: &mut Editor| {
|
||||||
let doc = doc!(editor);
|
let doc = doc!(editor);
|
||||||
@ -420,9 +417,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
|
|||||||
let response: Option<Vec<lsp::SymbolInformation>> =
|
let response: Option<Vec<lsp::SymbolInformation>> =
|
||||||
serde_json::from_value(json)?;
|
serde_json::from_value(json)?;
|
||||||
|
|
||||||
response.ok_or_else(|| {
|
Ok(response.unwrap_or_default())
|
||||||
anyhow::anyhow!("No response for workspace symbols from language server")
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
future.boxed()
|
future.boxed()
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user