@@ -11,11 +11,20 @@ use helix_view::editor::Action;
1111
1212use crate::{
1313 compositor::{self, Compositor},
14− ui::{self, overlay::overlayed, FilePicker, Popup, Prompt, PromptEvent},
14+ ui::{self, overlay::overlayed, FileLocation, FilePicker, Popup, Prompt, PromptEvent},
1515};
1616
1717use std::borrow::Cow;
1818
19+fn location_to_file_location(location: &lsp::Location) -> FileLocation {
20+ let path = location.uri.to_file_path().unwrap();
21+ let line = Some((
22+ location.range.start.line as usize,
23+ location.range.end.line as usize,
24+ ));
25+ (path, line)
26+}
27+
1928fn sym_picker(
2029 symbols: Vec<lsp::SymbolInformation>,
2130 current_path: Option<lsp::Url>,
@@ -55,14 +64,7 @@ fn sym_picker(
5564 align_view(doc, view, Align::Center);
5665 }
5766 },
58− move |_editor, symbol| {
59− let path = symbol.location.uri.to_file_path().unwrap();
60− let line = Some((
61− symbol.location.range.start.line as usize,
62− symbol.location.range.end.line as usize,
63− ));
64− Some((path, line))
65− },
67+ move |_editor, symbol| Some(location_to_file_location(&symbol.location)),
6668 );
6769 picker.truncate_start = false;
6870 picker
@@ -465,15 +467,7 @@ fn goto_impl(
465467 format!("{}:{}", file, line).into()
466468 },
467469 move |cx, location, action| jump_to(cx.editor, location, offset_encoding, action),
468− |_editor, location| {
469− // TODO: share code for symbol.location and location
470− let path = location.uri.to_file_path().unwrap();
471− let line = Some((
472− location.range.start.line as usize,
473− location.range.end.line as usize,
474− ));
475− Some((path, line))
476− },
470+ move |_editor, location| Some(location_to_file_location(location)),
477471 );
478472 compositor.push(Box::new(overlayed(picker)));
479473 }