mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-10 10:35:16 +03:00
add picker: current view dir (#4666)
This commit is contained in:
parent
61e1e6160a
commit
8ba0a46274
@ -276,6 +276,7 @@ impl MappableCommand {
|
|||||||
append_mode, "Append after selection",
|
append_mode, "Append after selection",
|
||||||
command_mode, "Enter command mode",
|
command_mode, "Enter command mode",
|
||||||
file_picker, "Open file picker",
|
file_picker, "Open file picker",
|
||||||
|
file_picker_in_current_buffer_directory, "Open file picker at current buffers's directory",
|
||||||
file_picker_in_current_directory, "Open file picker at current working directory",
|
file_picker_in_current_directory, "Open file picker at current working directory",
|
||||||
code_action, "Perform code action",
|
code_action, "Perform code action",
|
||||||
buffer_picker, "Open buffer picker",
|
buffer_picker, "Open buffer picker",
|
||||||
@ -2401,6 +2402,22 @@ fn file_picker(cx: &mut Context) {
|
|||||||
cx.push_layer(Box::new(overlayed(picker)));
|
cx.push_layer(Box::new(overlayed(picker)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn file_picker_in_current_buffer_directory(cx: &mut Context) {
|
||||||
|
let doc_dir = doc!(cx.editor)
|
||||||
|
.path()
|
||||||
|
.and_then(|path| path.parent().map(|path| path.to_path_buf()));
|
||||||
|
|
||||||
|
let path = match doc_dir {
|
||||||
|
Some(path) => path,
|
||||||
|
None => {
|
||||||
|
cx.editor.set_error("current buffer has no path or parent");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let picker = ui::file_picker(path, &cx.editor.config());
|
||||||
|
cx.push_layer(Box::new(overlayed(picker)));
|
||||||
|
}
|
||||||
fn file_picker_in_current_directory(cx: &mut Context) {
|
fn file_picker_in_current_directory(cx: &mut Context) {
|
||||||
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./"));
|
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./"));
|
||||||
let picker = ui::file_picker(cwd, &cx.editor.config());
|
let picker = ui::file_picker(cwd, &cx.editor.config());
|
||||||
|
Loading…
Reference in New Issue
Block a user