gd now works for singular definition
This commit is contained in:
parent
18ec8adc7f
commit
0322c28e6b
2 changed files with 8 additions and 2 deletions
|
@ -603,8 +603,6 @@ impl Client {
|
|||
|
||||
let response = self.request::<lsp::request::GotoDefinition>(params).await?;
|
||||
|
||||
println!("{:?}", response);
|
||||
|
||||
let items = match response {
|
||||
Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
|
||||
Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
|
||||
|
|
|
@ -861,6 +861,14 @@ pub fn goto_definition(cx: &mut Context) {
|
|||
let res =
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue