diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index d535968ec..753a899de 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -283,12 +283,15 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi type FileExplorer = Picker<(PathBuf, bool), (PathBuf, Style)>; +type OnConfirm = fn(cx: &mut Context, picker_root: PathBuf, &str, &Path) -> Option>; + fn create_confirmation_prompt( input: String, cx: &mut Context, - to_create_str: String, - to_create: PathBuf, - callback: fn(&str, &Path) -> Option>, + operation_input_str: String, + operation_input: PathBuf, + picker_root: PathBuf, + on_confirm: OnConfirm, ) { let callback = Box::pin(async move { let call: Callback = Callback::EditorCompositor(Box::new(move |_editor, compositor| { @@ -301,7 +304,7 @@ fn create_confirmation_prompt( return; }; - match callback(&to_create_str, &to_create) { + match on_confirm(cx, picker_root.clone(), &operation_input_str, &operation_input) { Some(Ok(msg)) => cx.editor.set_status(msg), Some(Err(msg)) => cx.editor.set_error(msg), None => (), @@ -361,6 +364,19 @@ fn create_file_operation_prompt( cx.jobs.callback(callback); } +fn refresh(cx: &mut Context, root: PathBuf) { + let callback = Box::pin(async move { + let call: Callback = + Callback::EditorCompositor(Box::new(move |editor, compositor| { + if let Ok(picker) = file_explorer(root, editor) { + compositor.push(Box::new(overlay::overlaid(picker))); + } + })); + Ok(call) + }); + cx.jobs.callback(callback); +} + pub fn file_explorer(root: PathBuf, editor: &Editor) -> Result { let directory_style = editor.theme.get("ui.text.directory"); let directory_content = directory_content(&root)?; @@ -385,16 +401,7 @@ pub fn file_explorer(root: PathBuf, editor: &Editor) -> Result Result Result Result Result Result Result Result Result Result Result Result Result