From 535e6ee77bdd2d285757d2fd9eab1fa291edeaaa Mon Sep 17 00:00:00 2001 From: ishanray <5403397+ishanray@users.noreply.github.com> Date: Fri, 22 Aug 2025 09:30:31 -0400 Subject: [PATCH] Make buffer picker default to last file (#14176) --- helix-term/src/commands.rs | 2 ++ helix-term/src/ui/picker.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 0d8c25500..18f24a634 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3199,9 +3199,11 @@ fn buffer_picker(cx: &mut Context) { .into() }), ]; + let initial_cursor = if items.len() <= 1 { 0 } else { 1 }; let picker = Picker::new(columns, 2, items, (), |cx, meta, action| { cx.editor.switch(meta.id, action); }) + .with_initial_cursor(initial_cursor) .with_preview(|editor, meta| { let doc = &editor.documents.get(&meta.id)?; let lines = doc.selections().values().next().map(|selection| { diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index a6a0e17ce..74b7873ed 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -426,6 +426,11 @@ impl Picker { self } + pub fn with_initial_cursor(mut self, cursor: u32) -> Self { + self.cursor = cursor; + self + } + pub fn with_dynamic_query( mut self, callback: DynQueryCallback,