Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error message shown for goto references #9382

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,9 @@ fn goto_impl(
[location] => {
jump_to_location(editor, location, offset_encoding, Action::Replace);
}
// XXX: All call sites pass non empty containers. This pattern is redundant.
theteachr marked this conversation as resolved.
Show resolved Hide resolved
[] => {
editor.set_error("No definition found.");
editor.set_error("No results found.");
}
_locations => {
let picker = Picker::new(locations, cwdir, move |cx, location, action| {
Expand Down Expand Up @@ -1065,9 +1066,11 @@ where

cx.callback(
future,
move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| {
let items = to_locations(response);
goto_impl(editor, compositor, items, offset_encoding);
move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| match to_locations(
theteachr marked this conversation as resolved.
Show resolved Hide resolved
response,
) {
items if items.is_empty() => editor.set_error("No definition found."),
items => goto_impl(editor, compositor, items, offset_encoding),
},
);
}
Expand Down Expand Up @@ -1125,9 +1128,11 @@ pub fn goto_reference(cx: &mut Context) {

cx.callback(
future,
move |editor, compositor, response: Option<Vec<lsp::Location>>| {
let items = response.unwrap_or_default();
goto_impl(editor, compositor, items, offset_encoding);
move |editor, compositor, response: Option<Vec<lsp::Location>>| match response
.unwrap_or_default()
{
items if items.is_empty() => editor.set_error("No references found."),
items => goto_impl(editor, compositor, items, offset_encoding),
},
);
}
Expand Down
Loading