From a4b5b4c16bbfc65efce7cddcd4e0c36fb0e2d4b0 Mon Sep 17 00:00:00 2001 From: woojiq Date: Wed, 31 Jan 2024 17:15:15 +0200 Subject: [PATCH] picker(jumplist): show newest options on top instead of bottom --- helix-term/src/commands.rs | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index c645849f1d290..b0741cc1ab657 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2974,27 +2974,27 @@ fn jumplist_picker(cx: &mut Context) { } }; - let picker = Picker::new( - cx.editor - .tree - .views() - .flat_map(|(view, _)| { - view.jumps - .iter() - .map(|(doc_id, selection)| new_meta(view, *doc_id, selection.clone())) - }) - .collect(), - (), - |cx, meta, action| { - cx.editor.switch(meta.id, action); - let config = cx.editor.config(); - let (view, doc) = (view_mut!(cx.editor), doc_mut!(cx.editor, &meta.id)); - doc.set_selection(view.id, meta.selection.clone()); - if action.align_view(view, doc.id()) { - view.ensure_cursor_in_view_center(doc, config.scrolloff); - } - }, - ) + let mut options: Vec = cx + .editor + .tree + .views() + .flat_map(|(view, _)| { + view.jumps + .iter() + .map(|(doc_id, selection)| new_meta(view, *doc_id, selection.clone())) + }) + .collect(); + options.reverse(); + + let picker = Picker::new(options, (), |cx, meta, action| { + cx.editor.switch(meta.id, action); + let config = cx.editor.config(); + let (view, doc) = (view_mut!(cx.editor), doc_mut!(cx.editor, &meta.id)); + doc.set_selection(view.id, meta.selection.clone()); + if action.align_view(view, doc.id()) { + view.ensure_cursor_in_view_center(doc, config.scrolloff); + } + }) .with_preview(|editor, meta| { let doc = &editor.documents.get(&meta.id)?; let line = meta.selection.primary().cursor_line(doc.text().slice(..));