mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-11-10 14:46:04 +03:00
gd now works for singular definition
This commit is contained in:
parent
18ec8adc7f
commit
0322c28e6b
@ -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 New Issue
Block a user