mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 10:56:19 +04:00
Fix error message shown for goto references (#9382)
This commit is contained in:
parent
cda8ea991e
commit
d8b8d2fda6
@ -1007,6 +1007,7 @@ pub fn apply_workspace_edit(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Precondition: `locations` should be non-empty.
|
||||||
fn goto_impl(
|
fn goto_impl(
|
||||||
editor: &mut Editor,
|
editor: &mut Editor,
|
||||||
compositor: &mut Compositor,
|
compositor: &mut Compositor,
|
||||||
@ -1019,9 +1020,7 @@ fn goto_impl(
|
|||||||
[location] => {
|
[location] => {
|
||||||
jump_to_location(editor, location, offset_encoding, Action::Replace);
|
jump_to_location(editor, location, offset_encoding, Action::Replace);
|
||||||
}
|
}
|
||||||
[] => {
|
[] => unreachable!("`locations` should be non-empty for `goto_impl`"),
|
||||||
editor.set_error("No definition found.");
|
|
||||||
}
|
|
||||||
_locations => {
|
_locations => {
|
||||||
let picker = Picker::new(locations, cwdir, move |cx, location, action| {
|
let picker = Picker::new(locations, cwdir, move |cx, location, action| {
|
||||||
jump_to_location(cx.editor, location, offset_encoding, action)
|
jump_to_location(cx.editor, location, offset_encoding, action)
|
||||||
@ -1063,7 +1062,11 @@ fn goto_single_impl<P, F>(cx: &mut Context, feature: LanguageServerFeature, requ
|
|||||||
future,
|
future,
|
||||||
move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| {
|
move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| {
|
||||||
let items = to_locations(response);
|
let items = to_locations(response);
|
||||||
|
if items.is_empty() {
|
||||||
|
editor.set_error("No definition found.");
|
||||||
|
} else {
|
||||||
goto_impl(editor, compositor, items, offset_encoding);
|
goto_impl(editor, compositor, items, offset_encoding);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1123,7 +1126,11 @@ pub fn goto_reference(cx: &mut Context) {
|
|||||||
future,
|
future,
|
||||||
move |editor, compositor, response: Option<Vec<lsp::Location>>| {
|
move |editor, compositor, response: Option<Vec<lsp::Location>>| {
|
||||||
let items = response.unwrap_or_default();
|
let items = response.unwrap_or_default();
|
||||||
|
if items.is_empty() {
|
||||||
|
editor.set_error("No references found.");
|
||||||
|
} else {
|
||||||
goto_impl(editor, compositor, items, offset_encoding);
|
goto_impl(editor, compositor, items, offset_encoding);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user