@@ -35,6 +35,32 @@ fn location_to_file_location(location: &lsp::Location) -> FileLocation {
35 (path, line)
35 (path, line)
38+// TODO: share with symbol picker(symbol.location)
39+// TODO: need to use push_jump() before?
42+ location: &lsp::Location,
43+ offset_encoding: OffsetEncoding,
49+ .expect("unable to convert URI to filepath");
50+ let _id = editor.open(path, action).expect("editor.open failed");
51+ let (view, doc) = current!(editor);
52+ let definition_pos = location.range.start;
53+ // TODO: convert inside server
54+ let new_pos = if let Some(new_pos) = lsp_pos_to_pos(doc.text(), definition_pos, offset_encoding)
60+ doc.set_selection(view.id, Selection::point(new_pos));
61+ align_view(doc, view, Align::Center);
38fn sym_picker(
64fn sym_picker(
39 symbols: Vec<lsp::SymbolInformation>,
65 symbols: Vec<lsp::SymbolInformation>,
40 current_path: Option<lsp::Url>,
66 current_path: Option<lsp::Url>,
@@ -407,36 +433,11 @@ fn goto_impl(
408 push_jump(editor);
434 push_jump(editor);
410− // TODO: share with symbol picker(symbol.location)
412− editor: &mut Editor,
413− location: &lsp::Location,
414− offset_encoding: OffsetEncoding,
420− .expect("unable to convert URI to filepath");
421− let _id = editor.open(path, action).expect("editor.open failed");
422− let (view, doc) = current!(editor);
423− let definition_pos = location.range.start;
424− // TODO: convert inside server
426− if let Some(new_pos) = lsp_pos_to_pos(doc.text(), definition_pos, offset_encoding) {
431− doc.set_selection(view.id, Selection::point(new_pos));
432− align_view(doc, view, Align::Center);
435 let cwdir = std::env::current_dir().expect("couldn't determine current directory");
436 let cwdir = std::env::current_dir().expect("couldn't determine current directory");
437 match locations.as_slice() {
438 match locations.as_slice() {
438 [location] => {
439 [location] => {
439− jump_to(editor, location, offset_encoding, Action::Replace);
440+ jump_to_location(editor, location, offset_encoding, Action::Replace);
442 editor.set_error("No definition found.");
443 editor.set_error("No definition found.");
@@ -464,7 +465,9 @@ fn goto_impl(
464 let line = location.range.start.line;
465 let line = location.range.start.line;
465 format!("{}:{}", file, line).into()
466 format!("{}:{}", file, line).into()
468+ move |cx, location, action| {
467− move |cx, location, action| jump_to(cx.editor, location, offset_encoding, action),
469+ jump_to_location(cx.editor, location, offset_encoding, action)
468 move |_editor, location| Some(location_to_file_location(location)),
471 move |_editor, location| Some(location_to_file_location(location)),
470 compositor.push(Box::new(overlayed(picker)));
473 compositor.push(Box::new(overlayed(picker)));