@@ -240,44 +240,40 @@ type SymbolPicker = FilePicker<SymbolInformationItem>;
241fn sym_picker(symbols: Vec<SymbolInformationItem>, current_path: Option<lsp::Url>) -> SymbolPicker {
241fn sym_picker(symbols: Vec<SymbolInformationItem>, current_path: Option<lsp::Url>) -> SymbolPicker {
242 // TODO: drop current_path comparison and instead use workspace: bool flag?
242 // TODO: drop current_path comparison and instead use workspace: bool flag?
245− current_path.clone(),
243+ FilePicker::new(symbols, current_path.clone(), move |cx, item, action| {
246− move |cx, item, action| {
247− let (view, doc) = current!(cx.editor);
244+ let (view, doc) = current!(cx.editor);
248− push_jump(view, doc);
245+ push_jump(view, doc);
250− if current_path.as_ref() != Some(&item.symbol.location.uri) {
247+ if current_path.as_ref() != Some(&item.symbol.location.uri) {
251− let uri = &item.symbol.location.uri;
248+ let uri = &item.symbol.location.uri;
252− let path = match uri.to_file_path() {
249+ let path = match uri.to_file_path() {
253− Ok(path) => path,
250+ Ok(path) => path,
254− Err(_) => {
251+ Err(_) => {
255− let err = format!("unable to convert URI to filepath: {}", uri);
252+ let err = format!("unable to convert URI to filepath: {}", uri);
256− cx.editor.set_error(err);
260− if let Err(err) = cx.editor.open(&path, action) {
261− let err = format!("failed to open document: {}: {}", uri, err);
262− log::error!("{}", err);
263 cx.editor.set_error(err);
253 cx.editor.set_error(err);
257+ if let Err(err) = cx.editor.open(&path, action) {
258+ let err = format!("failed to open document: {}: {}", uri, err);
259+ log::error!("{}", err);
260+ cx.editor.set_error(err);
268− let (view, doc) = current!(cx.editor);
265+ let (view, doc) = current!(cx.editor);
270− if let Some(range) =
267+ if let Some(range) =
271− lsp_range_to_range(doc.text(), item.symbol.location.range, item.offset_encoding)
268+ lsp_range_to_range(doc.text(), item.symbol.location.range, item.offset_encoding)
273− // we flip the range so that the cursor sits on the start of the symbol
270+ // we flip the range so that the cursor sits on the start of the symbol
274− // (for example start of the function).
271+ // (for example start of the function).
275− doc.set_selection(view.id, Selection::single(range.head, range.anchor));
272+ doc.set_selection(view.id, Selection::single(range.head, range.anchor));
276− align_view(doc, view, Align::Center);
273+ align_view(doc, view, Align::Center);
279− move |_editor, item| Some(location_to_file_location(&item.symbol.location)),
276+ .with_preview(move |_editor, item| Some(location_to_file_location(&item.symbol.location)))
281 .truncate_start(false)
277 .truncate_start(false)
@@ -345,11 +341,11 @@ fn diag_picker(
345 align_view(doc, view, Align::Center);
341 align_view(doc, view, Align::Center);
348− move |_editor, PickerDiagnostic { url, diag, .. }| {
349− let location = lsp::Location::new(url.clone(), diag.range);
350− Some(location_to_file_location(&location))
345+ .with_preview(move |_editor, PickerDiagnostic { url, diag, .. }| {
346+ let location = lsp::Location::new(url.clone(), diag.range);
347+ Some(location_to_file_location(&location))
353 .truncate_start(false)
349 .truncate_start(false)
@@ -1047,14 +1043,10 @@ fn goto_impl(
1047 editor.set_error("No definition found.");
1043 editor.set_error("No definition found.");
1049 _locations => {
1045 _locations => {
1050− let picker = FilePicker::new(
1046+ let picker = FilePicker::new(locations, cwdir, move |cx, location, action| {
1053− move |cx, location, action| {
1054− jump_to_location(cx.editor, location, offset_encoding, action)
1047+ jump_to_location(cx.editor, location, offset_encoding, action)
1056− move |_editor, location| Some(location_to_file_location(location)),
1049+ .with_preview(move |_editor, location| Some(location_to_file_location(location)));
1058 compositor.push(Box::new(overlaid(picker)));
1050 compositor.push(Box::new(overlaid(picker)));