@@ -240,44 +240,40 @@ type SymbolPicker = FilePicker<SymbolInformationItem>;
240240
241241fn sym_picker(symbols: Vec<SymbolInformationItem>, current_path: Option<lsp::Url>) -> SymbolPicker {
242242 // TODO: drop current_path comparison and instead use workspace: bool flag?
243− FilePicker::new(
244− symbols,
245− current_path.clone(),
246− move |cx, item, action| {
247− let (view, doc) = current!(cx.editor);
248− push_jump(view, doc);
249−
250− if current_path.as_ref() != Some(&item.symbol.location.uri) {
251− let uri = &item.symbol.location.uri;
252− let path = match uri.to_file_path() {
253− Ok(path) => path,
254− Err(_) => {
255− let err = format!("unable to convert URI to filepath: {}", uri);
256− cx.editor.set_error(err);
257− return;
258− }
259− };
260− if let Err(err) = cx.editor.open(&path, action) {
261− let err = format!("failed to open document: {}: {}", uri, err);
262− log::error!("{}", err);
243+ FilePicker::new(symbols, current_path.clone(), move |cx, item, action| {
244+ let (view, doc) = current!(cx.editor);
245+ push_jump(view, doc);
246+
247+ if current_path.as_ref() != Some(&item.symbol.location.uri) {
248+ let uri = &item.symbol.location.uri;
249+ let path = match uri.to_file_path() {
250+ Ok(path) => path,
251+ Err(_) => {
252+ let err = format!("unable to convert URI to filepath: {}", uri);
263253 cx.editor.set_error(err);
264254 return;
265255 }
256+ };
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);
261+ return;
266262 }
263+ }
267264
268− let (view, doc) = current!(cx.editor);
265+ let (view, doc) = current!(cx.editor);
269266
270− if let Some(range) =
271− lsp_range_to_range(doc.text(), item.symbol.location.range, item.offset_encoding)
272− {
273− // we flip the range so that the cursor sits on the start of the symbol
274− // (for example start of the function).
275− doc.set_selection(view.id, Selection::single(range.head, range.anchor));
276− align_view(doc, view, Align::Center);
277− }
278− },
279− move |_editor, item| Some(location_to_file_location(&item.symbol.location)),
280− )
267+ if let Some(range) =
268+ lsp_range_to_range(doc.text(), item.symbol.location.range, item.offset_encoding)
269+ {
270+ // we flip the range so that the cursor sits on the start of the symbol
271+ // (for example start of the function).
272+ doc.set_selection(view.id, Selection::single(range.head, range.anchor));
273+ align_view(doc, view, Align::Center);
274+ }
275+ })
276+ .with_preview(move |_editor, item| Some(location_to_file_location(&item.symbol.location)))
281277 .truncate_start(false)
282278}
283279
@@ -345,11 +341,11 @@ fn diag_picker(
345341 align_view(doc, view, Align::Center);
346342 }
347343 },
348− move |_editor, PickerDiagnostic { url, diag, .. }| {
349− let location = lsp::Location::new(url.clone(), diag.range);
350− Some(location_to_file_location(&location))
351− },
352344 )
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))
348+ })
353349 .truncate_start(false)
354350}
355351
@@ -1047,14 +1043,10 @@ fn goto_impl(
10471043 editor.set_error("No definition found.");
10481044 }
10491045 _locations => {
1050− let picker = FilePicker::new(
1051− locations,
1052− cwdir,
1053− move |cx, location, action| {
1054− jump_to_location(cx.editor, location, offset_encoding, action)
1055− },
1056− move |_editor, location| Some(location_to_file_location(location)),
1057− );
1046+ let picker = FilePicker::new(locations, cwdir, move |cx, location, action| {
1047+ jump_to_location(cx.editor, location, offset_encoding, action)
1048+ })
1049+ .with_preview(move |_editor, location| Some(location_to_file_location(location)));
10581050 compositor.push(Box::new(overlaid(picker)));
10591051 }
10601052 }