From 0322c28e6bc1f3bf13842b7db47aafbe5752d45c Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Tue, 23 Feb 2021 23:56:06 +0100 Subject: gd now works for singular definition --- helix-term/src/commands.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'helix-term') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index fee4f362..b2809f96 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -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; } -- cgit v1.2.3-70-g09d2