@@ -195,7 +195,6 @@ fn location_to_file_location(location: &lsp::Location) -> FileLocation {
195 (path.into(), line)
195 (path.into(), line)
198−// TODO: share with symbol picker(symbol.location)
199fn jump_to_location(
198fn jump_to_location(
200 editor: &mut Editor,
199 editor: &mut Editor,
201 location: &lsp::Location,
200 location: &lsp::Location,
@@ -213,15 +212,16 @@ fn jump_to_location(
216− match editor.open(&path, action) {
216+ let doc = match editor.open(&path, action) {
217− Ok(_) => (),
217+ Ok(id) => doc_mut!(editor, &id),
218 Err(err) => {
218 Err(err) => {
219 let err = format!("failed to open path: {:?}: {:?}", location.uri, err);
219 let err = format!("failed to open path: {:?}: {:?}", location.uri, err);
220 editor.set_error(err);
220 editor.set_error(err);
224− let (view, doc) = current!(editor);
224+ let view = view_mut!(editor);
225 // TODO: convert inside server
225 // TODO: convert inside server
226 let new_range =
226 let new_range =
227 if let Some(new_range) = lsp_range_to_range(doc.text(), location.range, offset_encoding) {
227 if let Some(new_range) = lsp_range_to_range(doc.text(), location.range, offset_encoding) {
@@ -233,45 +233,22 @@ fn jump_to_location(
233 // we flip the range so that the cursor sits on the start of the symbol
233 // we flip the range so that the cursor sits on the start of the symbol
234 // (for example start of the function).
234 // (for example start of the function).
235 doc.set_selection(view.id, Selection::single(new_range.head, new_range.anchor));
235 doc.set_selection(view.id, Selection::single(new_range.head, new_range.anchor));
236+ if action.align_view(view, doc.id()) {
236− align_view(doc, view, Align::Center);
237+ align_view(doc, view, Align::Center);
239type SymbolPicker = Picker<SymbolInformationItem>;
241type SymbolPicker = Picker<SymbolInformationItem>;
241fn sym_picker(symbols: Vec<SymbolInformationItem>, current_path: Option<lsp::Url>) -> SymbolPicker {
243fn sym_picker(symbols: Vec<SymbolInformationItem>, current_path: Option<lsp::Url>) -> SymbolPicker {
242 // TODO: drop current_path comparison and instead use workspace: bool flag?
244 // TODO: drop current_path comparison and instead use workspace: bool flag?
243− Picker::new(symbols, current_path.clone(), move |cx, item, action| {
245+ Picker::new(symbols, current_path, move |cx, item, action| {
244− let (view, doc) = current!(cx.editor);
247+ cx.editor,
245− push_jump(view, doc);
247− if current_path.as_ref() != Some(&item.symbol.location.uri) {
248− let uri = &item.symbol.location.uri;
248+ &item.symbol.location,
249− let path = match uri.to_file_path() {
252− let err = format!("unable to convert URI to filepath: {}", uri);
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);
265− let (view, doc) = current!(cx.editor);
267− if let Some(range) =
268− lsp_range_to_range(doc.text(), item.symbol.location.range, item.offset_encoding)
249+ item.offset_encoding,
270− // we flip the range so that the cursor sits on the start of the symbol
251+ );
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);
276 .with_preview(move |_editor, item| Some(location_to_file_location(&item.symbol.location)))
253 .with_preview(move |_editor, item| Some(location_to_file_location(&item.symbol.location)))
277 .truncate_start(false)
254 .truncate_start(false)
@@ -286,7 +263,7 @@ enum DiagnosticsFormat {
286fn diag_picker(
263fn diag_picker(
287 cx: &Context,
264 cx: &Context,
288 diagnostics: BTreeMap<lsp::Url, Vec<(lsp::Diagnostic, usize)>>,
265 diagnostics: BTreeMap<lsp::Url, Vec<(lsp::Diagnostic, usize)>>,
289− current_path: Option<lsp::Url>,
266+ _current_path: Option<lsp::Url>,
290 format: DiagnosticsFormat,
267 format: DiagnosticsFormat,
291) -> Picker<PickerDiagnostic> {
268) -> Picker<PickerDiagnostic> {
292 // TODO: drop current_path comparison and instead use workspace: bool flag?
269 // TODO: drop current_path comparison and instead use workspace: bool flag?
@@ -324,22 +301,12 @@ fn diag_picker(
324 offset_encoding,
301 offset_encoding,
326 action| {
303 action| {
327− if current_path.as_ref() == Some(url) {
304+ jump_to_location(
328− let (view, doc) = current!(cx.editor);
305+ cx.editor,
329− push_jump(view, doc);
306+ &lsp::Location::new(url.clone(), diag.range),
330− } else {
307+ *offset_encoding,
331− let path = url.to_file_path().unwrap();
308+ action,
332− cx.editor.open(&path, action).expect("editor.open failed");
309+ )
335− let (view, doc) = current!(cx.editor);
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);
345 .with_preview(move |_editor, PickerDiagnostic { url, diag, .. }| {
312 .with_preview(move |_editor, PickerDiagnostic { url, diag, .. }| {