gd now works for singular definition

pull/8/head
Jan Hrastnik 4 years ago committed by Blaž Hrastnik
parent 18ec8adc7f
commit 0322c28e6b

@ -603,8 +603,6 @@ impl Client {
let response = self.request::<lsp::request::GotoDefinition>(params).await?; let response = self.request::<lsp::request::GotoDefinition>(params).await?;
println!("{:?}", response);
let items = match response { let items = match response {
Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location], Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec, Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,

@ -861,6 +861,14 @@ pub fn goto_definition(cx: &mut Context) {
let res = let res =
smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default(); smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
if res.len() == 1 {
let definition_pos = res.get(0).unwrap().range.start;
let new_pos = helix_lsp::util::lsp_pos_to_pos(doc.text().slice(..), definition_pos);
doc.set_selection(Selection::point(new_pos));
} else {
// show menu picker i guess
}
doc.mode = Mode::Normal; doc.mode = Mode::Normal;
} }

Loading…
Cancel
Save