feat: figure out how to pass custom callback function set by keymap to picker

pull/12902/head
Nikita Revenco 2025-02-17 21:09:04 +00:00
parent 87b5bd58bc
commit f4e5c26112
1 changed files with 11 additions and 3 deletions

View File

@ -14,11 +14,12 @@ mod statusline;
mod text; mod text;
mod text_decorations; mod text_decorations;
use crate::compositor::Compositor; use crate::compositor::{Compositor, Context};
use crate::filter_picker_entry;
use crate::job::{self, Callback}; use crate::job::{self, Callback};
use crate::{ctrl, filter_picker_entry};
pub use completion::Completion; pub use completion::Completion;
pub use editor::EditorView; pub use editor::EditorView;
use helix_core::hashmap;
use helix_stdx::rope; use helix_stdx::rope;
use helix_view::theme::Style; use helix_view::theme::Style;
pub use markdown::Markdown; pub use markdown::Markdown;
@ -32,6 +33,7 @@ pub use text::Text;
use helix_view::Editor; use helix_view::Editor;
use tui::text::Span; use tui::text::Span;
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use std::{error::Error, path::PathBuf}; use std::{error::Error, path::PathBuf};
@ -296,6 +298,11 @@ pub fn file_explorer(root: PathBuf, editor: &Editor) -> Result<FileExplorer, std
} }
}, },
)]; )];
let delete_file: Box<dyn Fn(&mut Context) + 'static> = Box::new(|cx: &mut Context| {
log::error!("1");
});
let picker = Picker::new( let picker = Picker::new(
columns, columns,
0, 0,
@ -324,7 +331,8 @@ pub fn file_explorer(root: PathBuf, editor: &Editor) -> Result<FileExplorer, std
} }
}, },
) )
.with_preview(|_editor, (path, _is_dir)| Some((path.as_path().into(), None))); .with_preview(|_editor, (path, _is_dir)| Some((path.as_path().into(), None)))
.with_key_handler(hashmap!(ctrl!('x') => delete_file));
Ok(picker) Ok(picker)
} }