From b738ae1bc7f42ce6756ee5d79307e416f86ef491 Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Tue, 2 Mar 2021 23:57:18 +0100 Subject: more goto lsp functions --- helix-term/src/commands.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index f07a3933..9b48e803 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -872,11 +872,19 @@ pub fn goto_definition(cx: &mut Context) { doc.mode = Mode::Normal; + log::info!("{:?}", res); + let filepath = doc.path.clone().unwrap(); + log::info!("{:?}", filepath); + match &res.as_slice() { [location] => { - let definition_pos = location.range.start; - let new_pos = helix_lsp::util::lsp_pos_to_pos(doc.text().slice(..), definition_pos); - doc.set_selection(Selection::point(new_pos)); + if filepath.to_str().unwrap() == location.uri.path() { + let definition_pos = location.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 { + // open new file + } } [] => (), // maybe show user message that no definition was found? _ => { -- cgit v1.2.3-70-g09d2