Skip to content

Commit

Permalink
Merge pull request #1 from DenisKolodin/add-picker-current-view-dir-r…
Browse files Browse the repository at this point in the history
…efactor

Refactor a picker of the current view
  • Loading branch information
mangas committed Nov 19, 2022
2 parents 6aba9a9 + 7be5b8d commit 2f73ee9
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2269,22 +2269,18 @@ fn file_picker(cx: &mut Context) {
}

fn file_picker_in_current_buffer_directory(cx: &mut Context) {
let doc = doc!(cx.editor);

let doc_dir = match doc
let doc_dir = doc!(cx.editor)
.path()
.and_then(|path| path.parent().map(|path| path.to_path_buf()))
{
Some(path) => path,
None => {
cx.editor.set_error("current buffer has no path or parent");
return;
}
};

let picker = ui::file_picker(doc_dir, &cx.editor.config());
cx.push_layer(Box::new(overlayed(picker)));
.and_then(|path| path.parent())
.map(Path::to_path_buf);
if let Some(path) = doc_dir {
let picker = ui::file_picker(path, &cx.editor.config());
cx.push_layer(Box::new(overlayed(picker)));
} else {
cx.editor.set_error("current buffer has no path or parent");
}
}

fn file_picker_in_current_directory(cx: &mut Context) {
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./"));
let picker = ui::file_picker(cwd, &cx.editor.config());
Expand Down

0 comments on commit 2f73ee9

Please sign in to comment.