@@ -195,7 +195,6 @@ fn location_to_file_location(location: &lsp::Location) -> FileLocation {
195195 (path.into(), line)
196196}
197197
198−// TODO: share with symbol picker(symbol.location)
199198fn jump_to_location(
200199 editor: &mut Editor,
201200 location: &lsp::Location,
@@ -213,15 +212,16 @@ fn jump_to_location(
213212 return;
214213 }
215214 };
216− match editor.open(&path, action) {
217− Ok(_) => (),
215+
216+ let doc = match editor.open(&path, action) {
217+ Ok(id) => doc_mut!(editor, &id),
218218 Err(err) => {
219219 let err = format!("failed to open path: {:?}: {:?}", location.uri, err);
220220 editor.set_error(err);
221221 return;
222222 }
223− }
224− let (view, doc) = current!(editor);
223+ };
224+ let view = view_mut!(editor);
225225 // TODO: convert inside server
226226 let new_range =
227227 if let Some(new_range) = lsp_range_to_range(doc.text(), location.range, offset_encoding) {
@@ -233,45 +233,22 @@ fn jump_to_location(
233233 // we flip the range so that the cursor sits on the start of the symbol
234234 // (for example start of the function).
235235 doc.set_selection(view.id, Selection::single(new_range.head, new_range.anchor));
236− align_view(doc, view, Align::Center);
236+ if action.align_view(view, doc.id()) {
237+ align_view(doc, view, Align::Center);
238+ }
237239}
238240
239241type SymbolPicker = Picker<SymbolInformationItem>;
240242
241243fn sym_picker(symbols: Vec<SymbolInformationItem>, current_path: Option<lsp::Url>) -> SymbolPicker {
242244 // TODO: drop current_path comparison and instead use workspace: bool flag?
243− Picker::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);
253− cx.editor.set_error(err);
254− return;
255− }
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;
262− }
263− }
264−
265− let (view, doc) = current!(cx.editor);
266−
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− }
245+ Picker::new(symbols, current_path, move |cx, item, action| {
246+ jump_to_location(
247+ cx.editor,
248+ &item.symbol.location,
249+ item.offset_encoding,
250+ action,
251+ );
275252 })
276253 .with_preview(move |_editor, item| Some(location_to_file_location(&item.symbol.location)))
277254 .truncate_start(false)
@@ -286,7 +263,7 @@ enum DiagnosticsFormat {
286263fn diag_picker(
287264 cx: &Context,
288265 diagnostics: BTreeMap<lsp::Url, Vec<(lsp::Diagnostic, usize)>>,
289− current_path: Option<lsp::Url>,
266+ _current_path: Option<lsp::Url>,
290267 format: DiagnosticsFormat,
291268) -> Picker<PickerDiagnostic> {
292269 // TODO: drop current_path comparison and instead use workspace: bool flag?
@@ -324,22 +301,12 @@ fn diag_picker(
324301 offset_encoding,
325302 },
326303 action| {
327− if current_path.as_ref() == Some(url) {
328− let (view, doc) = current!(cx.editor);
329− push_jump(view, doc);
330− } else {
331− let path = url.to_file_path().unwrap();
332− cx.editor.open(&path, action).expect("editor.open failed");
333− }
334−
335− let (view, doc) = current!(cx.editor);
336−
337− if let Some(range) = lsp_range_to_range(doc.text(), diag.range, *offset_encoding) {
338− // we flip the range so that the cursor sits on the start of the symbol
339− // (for example start of the function).
340− doc.set_selection(view.id, Selection::single(range.head, range.anchor));
341− align_view(doc, view, Align::Center);
342− }
304+ jump_to_location(
305+ cx.editor,
306+ &lsp::Location::new(url.clone(), diag.range),
307+ *offset_encoding,
308+ action,
309+ )
343310 },
344311 )
345312 .with_preview(move |_editor, PickerDiagnostic { url, diag, .. }| {