@@ -852,27 +852,21 @@ pub fn exit_select_mode(cx: &mut Context) {
852852 cx.doc().mode = Mode::Normal;
853853}
854854
855−fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
855+fn goto(cx: &'static mut Context<'static>, locations: Vec<lsp::Location>) {
856856 let doc = cx.doc();
857857
858858 doc.mode = Mode::Normal;
859859
860860 log::info!("{:?}", locations);
861− let filepath = doc.path().unwrap();
862− log::info!("{:?}", filepath);
863861
864862 match locations.as_slice() {
865863 [location] => {
866− if filepath.to_str().unwrap() == location.uri.path() {
867− let definition_pos = location.range.start;
868− let new_pos = helix_lsp::util::lsp_pos_to_pos(doc.text().slice(..), definition_pos);
869− doc.set_selection(Selection::point(new_pos));
870− } else {
871− // open new file
872− cx.editor
873− .open(PathBuf::from(location.uri.path()), cx.executor);
874− // TODO: go to position
875− }
864+ cx.editor
865+ .open(PathBuf::from(location.uri.path()), cx.executor);
866+ let doc = cx.doc();
867+ let definition_pos = location.range.start;
868+ let new_pos = helix_lsp::util::lsp_pos_to_pos(doc.text().slice(..), definition_pos);
869+ doc.set_selection(Selection::point(new_pos));
876870 }
877871 [] => (), // maybe show user message that no definition was found?
878872 _locations => {
@@ -884,14 +878,20 @@ fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
884878 format!("{}:{}", file, line).into()
885879 },
886880 move |editor: &mut Editor, item| {
887− let doc = &mut editor.view_mut().doc;
881+ cx.editor.open(PathBuf::from(item.uri.path()), cx.executor);
882+ let doc = cx.doc();
883+ let definition_pos = item.range.start;
884+ let new_pos =
885+ helix_lsp::util::lsp_pos_to_pos(doc.text().slice(..), definition_pos);
886+ doc.set_selection(Selection::point(new_pos));
888887 },
889888 );
889+ cx.push_layer(Box::new(picker));
890890 }
891891 }
892892}
893893
894−pub fn goto_definition(cx: &mut Context) {
894+pub fn goto_definition(cx: &'static mut Context<'static>) {
895895 let doc = cx.doc();
896896 let language_server = match doc.language_server.as_ref() {
897897 Some(language_server) => language_server,
@@ -907,7 +907,7 @@ pub fn goto_definition(cx: &mut Context) {
907907 goto(cx, res);
908908}
909909
910−pub fn goto_type_definition(cx: &mut Context) {
910+pub fn goto_type_definition(cx: &'static mut Context<'static>) {
911911 let doc = cx.doc();
912912 let language_server = match doc.language_server.as_ref() {
913913 Some(language_server) => language_server,
@@ -923,7 +923,7 @@ pub fn goto_type_definition(cx: &mut Context) {
923923 goto(cx, res);
924924}
925925
926−pub fn goto_implementation(cx: &mut Context) {
926+pub fn goto_implementation(cx: &'static mut Context<'static>) {
927927 let doc = cx.doc();
928928 let language_server = match doc.language_server.as_ref() {
929929 Some(language_server) => language_server,
@@ -939,7 +939,7 @@ pub fn goto_implementation(cx: &mut Context) {
939939 goto(cx, res);
940940}
941941
942−pub fn goto_reference(cx: &mut Context) {
942+pub fn goto_reference(cx: &'static mut Context<'static>) {
943943 let doc = cx.doc();
944944 let language_server = match doc.language_server.as_ref() {
945945 Some(language_server) => language_server,