mirror of https://github.com/helix-editor/helix
refactor: do not explicitlys specify the types everywhere
parent
984ad4bca9
commit
a6e110937b
|
@ -425,8 +425,7 @@ pub fn file_explorer(
|
|||
},
|
||||
)];
|
||||
|
||||
let yank_path =
|
||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, _: Arc<ExplorerData>, _cursor: u32| {
|
||||
let yank_path: KeyHandler = Box::new(|cx, (path, _), _, _| {
|
||||
let register = cx
|
||||
.editor
|
||||
.selected_register
|
||||
|
@ -439,10 +438,9 @@ pub fn file_explorer(
|
|||
Ok(()) => cx.editor.set_status(message),
|
||||
Err(err) => cx.editor.set_error(err.to_string()),
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
let create_file =
|
||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, data: Arc<ExplorerData>, cursor: u32| {
|
||||
let create_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||
create_file_operation_prompt(
|
||||
cursor,
|
||||
"create:",
|
||||
|
@ -502,10 +500,9 @@ pub fn file_explorer(
|
|||
create_op(cursor, cx, root, to_create_str, &to_create)
|
||||
},
|
||||
)
|
||||
};
|
||||
});
|
||||
|
||||
let move_file =
|
||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, data: Arc<ExplorerData>, cursor: u32| {
|
||||
let move_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||
create_file_operation_prompt(
|
||||
cursor,
|
||||
"move:",
|
||||
|
@ -559,12 +556,9 @@ pub fn file_explorer(
|
|||
move_op(cursor, cx, root, move_to_str, move_from)
|
||||
},
|
||||
)
|
||||
};
|
||||
});
|
||||
|
||||
let delete_file = |cx: &mut Context,
|
||||
(path, _is_dir): &ExplorerItem,
|
||||
data: Arc<ExplorerData>,
|
||||
cursor: u32| {
|
||||
let delete_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||
create_file_operation_prompt(
|
||||
cursor,
|
||||
"delete? (y/n):",
|
||||
|
@ -602,10 +596,9 @@ pub fn file_explorer(
|
|||
}
|
||||
},
|
||||
)
|
||||
};
|
||||
});
|
||||
|
||||
let copy_file =
|
||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, data: Arc<ExplorerData>, cursor: u32| {
|
||||
let copy_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||
create_file_operation_prompt(
|
||||
cursor,
|
||||
"copy-to:",
|
||||
|
@ -669,7 +662,7 @@ pub fn file_explorer(
|
|||
}
|
||||
},
|
||||
)
|
||||
};
|
||||
});
|
||||
|
||||
let picker = Picker::new(
|
||||
columns,
|
||||
|
@ -702,11 +695,11 @@ pub fn file_explorer(
|
|||
.with_cursor(cursor.unwrap_or_default())
|
||||
.with_preview(|_editor, (path, _is_dir)| Some((path.as_path().into(), None)))
|
||||
.with_key_handlers(hashmap! {
|
||||
alt!('n') => Box::new(create_file) as KeyHandler,
|
||||
alt!('m') => Box::new(move_file) as KeyHandler,
|
||||
alt!('d') => Box::new(delete_file) as KeyHandler,
|
||||
alt!('c') => Box::new(copy_file) as KeyHandler,
|
||||
alt!('y') => Box::new(yank_path) as KeyHandler,
|
||||
alt!('n') => create_file,
|
||||
alt!('m') => move_file,
|
||||
alt!('d') => delete_file,
|
||||
alt!('c') => copy_file,
|
||||
alt!('y') => yank_path,
|
||||
});
|
||||
|
||||
Ok(picker)
|
||||
|
|
Loading…
Reference in New Issue