@@ -2789,35 +2789,28 @@ fn exit_select_mode(cx: &mut Context) {
2792−fn goto_pos(editor: &mut Editor, pos: usize) {
2793− let (view, doc) = current!(editor);
2795− push_jump(view, doc);
2796− doc.set_selection(view.id, Selection::point(pos));
2797− align_view(doc, view, Align::Center);
2800fn goto_first_diag(cx: &mut Context) {
2792fn goto_first_diag(cx: &mut Context) {
2801− let doc = doc!(cx.editor);
2793+ let (view, doc) = current!(cx.editor);
2802− let pos = match doc.diagnostics().first() {
2794+ let selection = match doc.diagnostics().first() {
2803− Some(diag) => diag.range.start,
2795+ Some(diag) => Selection::single(diag.range.start, diag.range.end),
2804 None => return,
2796 None => return,
2806− goto_pos(cx.editor, pos);
2798+ doc.set_selection(view.id, selection);
2799+ align_view(doc, view, Align::Center);
2809fn goto_last_diag(cx: &mut Context) {
2802fn goto_last_diag(cx: &mut Context) {
2810− let doc = doc!(cx.editor);
2803+ let (view, doc) = current!(cx.editor);
2811− let pos = match doc.diagnostics().last() {
2804+ let selection = match doc.diagnostics().last() {
2812− Some(diag) => diag.range.start,
2805+ Some(diag) => Selection::single(diag.range.start, diag.range.end),
2813 None => return,
2806 None => return,
2815− goto_pos(cx.editor, pos);
2808+ doc.set_selection(view.id, selection);
2809+ align_view(doc, view, Align::Center);
2818fn goto_next_diag(cx: &mut Context) {
2812fn goto_next_diag(cx: &mut Context) {
2819− let editor = &mut cx.editor;
2820− let (view, doc) = current!(editor);
2813+ let (view, doc) = current!(cx.editor);
2822 let cursor_pos = doc
2815 let cursor_pos = doc
2823 .selection(view.id)
2816 .selection(view.id)
@@ -2830,17 +2823,16 @@ fn goto_next_diag(cx: &mut Context) {
2830 .find(|diag| diag.range.start > cursor_pos)
2823 .find(|diag| diag.range.start > cursor_pos)
2831 .or_else(|| doc.diagnostics().first());
2824 .or_else(|| doc.diagnostics().first());
2833− let pos = match diag {
2826+ let selection = match diag {
2834− Some(diag) => diag.range.start,
2827+ Some(diag) => Selection::single(diag.range.start, diag.range.end),
2835 None => return,
2828 None => return,
2837−
2830+ doc.set_selection(view.id, selection);
2838− goto_pos(editor, pos);
2831+ align_view(doc, view, Align::Center);
2841fn goto_prev_diag(cx: &mut Context) {
2834fn goto_prev_diag(cx: &mut Context) {
2842− let editor = &mut cx.editor;
2843− let (view, doc) = current!(editor);
2835+ let (view, doc) = current!(cx.editor);
2845 let cursor_pos = doc
2837 let cursor_pos = doc
2846 .selection(view.id)
2838 .selection(view.id)
@@ -2854,12 +2846,14 @@ fn goto_prev_diag(cx: &mut Context) {
2854 .find(|diag| diag.range.start < cursor_pos)
2846 .find(|diag| diag.range.start < cursor_pos)
2855 .or_else(|| doc.diagnostics().last());
2847 .or_else(|| doc.diagnostics().last());
2857− let pos = match diag {
2849+ let selection = match diag {
2850+ // NOTE: the selection is reversed because we're jumping to the
2851+ // previous diagnostic.
2858− Some(diag) => diag.range.start,
2852+ Some(diag) => Selection::single(diag.range.end, diag.range.start),
2859 None => return,
2853 None => return,
2861−
2855+ doc.set_selection(view.id, selection);
2862− goto_pos(editor, pos);
2856+ align_view(doc, view, Align::Center);
2865fn goto_first_change(cx: &mut Context) {
2859fn goto_first_change(cx: &mut Context) {