mirror of
https://github.com/helix-editor/helix.git
synced 2025-10-06 00:13:28 +02:00
Make buffer picker default to last file (#14176)
This commit is contained in:
@@ -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| {
|
||||
|
@@ -426,6 +426,11 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_initial_cursor(mut self, cursor: u32) -> Self {
|
||||
self.cursor = cursor;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_dynamic_query(
|
||||
mut self,
|
||||
callback: DynQueryCallback<T, D>,
|
||||
|
Reference in New Issue
Block a user