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 =
|
let yank_path: KeyHandler = Box::new(|cx, (path, _), _, _| {
|
||||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, _: Arc<ExplorerData>, _cursor: u32| {
|
|
||||||
let register = cx
|
let register = cx
|
||||||
.editor
|
.editor
|
||||||
.selected_register
|
.selected_register
|
||||||
|
@ -439,10 +438,9 @@ pub fn file_explorer(
|
||||||
Ok(()) => cx.editor.set_status(message),
|
Ok(()) => cx.editor.set_status(message),
|
||||||
Err(err) => cx.editor.set_error(err.to_string()),
|
Err(err) => cx.editor.set_error(err.to_string()),
|
||||||
};
|
};
|
||||||
};
|
});
|
||||||
|
|
||||||
let create_file =
|
let create_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, data: Arc<ExplorerData>, cursor: u32| {
|
|
||||||
create_file_operation_prompt(
|
create_file_operation_prompt(
|
||||||
cursor,
|
cursor,
|
||||||
"create:",
|
"create:",
|
||||||
|
@ -502,10 +500,9 @@ pub fn file_explorer(
|
||||||
create_op(cursor, cx, root, to_create_str, &to_create)
|
create_op(cursor, cx, root, to_create_str, &to_create)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
};
|
});
|
||||||
|
|
||||||
let move_file =
|
let move_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, data: Arc<ExplorerData>, cursor: u32| {
|
|
||||||
create_file_operation_prompt(
|
create_file_operation_prompt(
|
||||||
cursor,
|
cursor,
|
||||||
"move:",
|
"move:",
|
||||||
|
@ -559,12 +556,9 @@ pub fn file_explorer(
|
||||||
move_op(cursor, cx, root, move_to_str, move_from)
|
move_op(cursor, cx, root, move_to_str, move_from)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
};
|
});
|
||||||
|
|
||||||
let delete_file = |cx: &mut Context,
|
let delete_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||||
(path, _is_dir): &ExplorerItem,
|
|
||||||
data: Arc<ExplorerData>,
|
|
||||||
cursor: u32| {
|
|
||||||
create_file_operation_prompt(
|
create_file_operation_prompt(
|
||||||
cursor,
|
cursor,
|
||||||
"delete? (y/n):",
|
"delete? (y/n):",
|
||||||
|
@ -602,10 +596,9 @@ pub fn file_explorer(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
};
|
});
|
||||||
|
|
||||||
let copy_file =
|
let copy_file: KeyHandler = Box::new(|cx, (path, _), data, cursor| {
|
||||||
|cx: &mut Context, (path, _is_dir): &ExplorerItem, data: Arc<ExplorerData>, cursor: u32| {
|
|
||||||
create_file_operation_prompt(
|
create_file_operation_prompt(
|
||||||
cursor,
|
cursor,
|
||||||
"copy-to:",
|
"copy-to:",
|
||||||
|
@ -669,7 +662,7 @@ pub fn file_explorer(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
};
|
});
|
||||||
|
|
||||||
let picker = Picker::new(
|
let picker = Picker::new(
|
||||||
columns,
|
columns,
|
||||||
|
@ -702,11 +695,11 @@ pub fn file_explorer(
|
||||||
.with_cursor(cursor.unwrap_or_default())
|
.with_cursor(cursor.unwrap_or_default())
|
||||||
.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_handlers(hashmap! {
|
.with_key_handlers(hashmap! {
|
||||||
alt!('n') => Box::new(create_file) as KeyHandler,
|
alt!('n') => create_file,
|
||||||
alt!('m') => Box::new(move_file) as KeyHandler,
|
alt!('m') => move_file,
|
||||||
alt!('d') => Box::new(delete_file) as KeyHandler,
|
alt!('d') => delete_file,
|
||||||
alt!('c') => Box::new(copy_file) as KeyHandler,
|
alt!('c') => copy_file,
|
||||||
alt!('y') => Box::new(yank_path) as KeyHandler,
|
alt!('y') => yank_path,
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(picker)
|
Ok(picker)
|
||||||
|
|
Loading…
Reference in New Issue