feat: tell user which path they are operating on

pull/12902/head
Nikita Revenco 2025-03-04 12:19:02 +00:00
parent 4133e14a5e
commit 42d74bb9fa
1 changed files with 11 additions and 6 deletions

View File

@ -346,7 +346,7 @@ type FileOperation = fn(PathBuf, u32, &mut Context, &Path, &str) -> Option<Resul
fn create_file_operation_prompt( fn create_file_operation_prompt(
cursor: u32, cursor: u32,
prompt: &'static str, prompt: fn(&Path) -> String,
cx: &mut Context, cx: &mut Context,
path: &Path, path: &Path,
data: Arc<ExplorerData>, data: Arc<ExplorerData>,
@ -357,7 +357,12 @@ fn create_file_operation_prompt(
let callback = Box::pin(async move { let callback = Box::pin(async move {
let call: Callback = Callback::EditorCompositor(Box::new(move |editor, compositor| { let call: Callback = Callback::EditorCompositor(Box::new(move |editor, compositor| {
let mut prompt = Prompt::new( let mut prompt = Prompt::new(
prompt.into(), editor
.file_explorer_selected_path
.as_ref()
.map(|p| prompt(p))
.unwrap_or_default()
.into(),
None, None,
crate::ui::completers::none, crate::ui::completers::none,
move |cx, input: &str, event: PromptEvent| { move |cx, input: &str, event: PromptEvent| {
@ -431,7 +436,7 @@ pub fn file_explorer(
let create: KeyHandler = Box::new(|cx, (path, _), data, cursor| { let create: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
create_file_operation_prompt( create_file_operation_prompt(
cursor, cursor,
"create:", |_| "create:".into(),
cx, cx,
path, path,
data, data,
@ -493,7 +498,7 @@ pub fn file_explorer(
let move_: KeyHandler = Box::new(|cx, (path, _), data, cursor| { let move_: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
create_file_operation_prompt( create_file_operation_prompt(
cursor, cursor,
"move:", |path| format!("Move {} to:", path.display()),
cx, cx,
path, path,
data, data,
@ -550,7 +555,7 @@ pub fn file_explorer(
let delete: KeyHandler = Box::new(|cx, (path, _), data, cursor| { let delete: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
create_file_operation_prompt( create_file_operation_prompt(
cursor, cursor,
"delete? (y/n):", |path| format!("Delete {}? (y/n):", path.display()),
cx, cx,
path, path,
data, data,
@ -590,7 +595,7 @@ pub fn file_explorer(
let copy: KeyHandler = Box::new(|cx, (path, _), data, cursor| { let copy: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
create_file_operation_prompt( create_file_operation_prompt(
cursor, cursor,
"copy-to:", |path| format!("Copy {} to:", path.display()),
cx, cx,
path, path,
data, data,