From dd2d562c1462a63f45418250261a151f753cfc63 Mon Sep 17 00:00:00 2001 From: Matt Paras Date: Tue, 3 Sep 2024 12:43:43 -0700 Subject: [PATCH] fix recent file picker --- helix-term/src/commands/engine/steel.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/helix-term/src/commands/engine/steel.rs b/helix-term/src/commands/engine/steel.rs index 227b0ab75..d2c74f552 100644 --- a/helix-term/src/commands/engine/steel.rs +++ b/helix-term/src/commands/engine/steel.rs @@ -51,7 +51,7 @@ use crate::{ events::{OnModeSwitch, PostCommand, PostInsertChar}, job::{self, Callback}, keymap::{self, merge_keys, KeyTrie, KeymapResult}, - ui::{self, picker::PathOrId, Popup, Prompt, PromptEvent}, + ui::{self, picker::PathOrId, PickerColumn, Popup, Prompt, PromptEvent}, }; use components::SteelDynamicComponent; @@ -2130,11 +2130,22 @@ fn configure_engine_impl(mut engine: Engine) -> Engine { ); engine.register_fn("picker", |values: Vec| -> WrappedDynComponent { + let columns = [PickerColumn::new( + "path", + |item: &PathBuf, root: &PathBuf| { + item.strip_prefix(root) + .unwrap_or(item) + .to_string_lossy() + .into() + }, + )]; + let cwd = helix_stdx::env::current_working_dir(); + let picker = ui::Picker::new( - Vec::new(), + columns, 0, [PathBuf::from("")], - (), + cwd, move |cx, path: &PathBuf, action| { if let Err(e) = cx.editor.open(path, action) { let err = if let Some(err) = e.source() {