on master help sign in
Show file picker when directory passed as first arg
commit43b92b24d2ed421625ff77c3a09a7909f7d82e02 authorwojciechkepka <wojtek.kepka@protonmail.com> dateWed 2 Jun 2021, 16:20 (5 years ago) parentb2b2d43
1 file changed+16−4
helix-term/src/application.rs+16−4
helix-term/src/application.rs+16−4
@@ -45,16 +45,28 @@ impl Application {
4545 let size = compositor.size();
4646 let mut editor = Editor::new(size);
4747
48+ compositor.push(Box::new(ui::EditorView::new()));
49+
4850 if !args.files.is_empty() {
49− for file in args.files {
50− editor.open(file, Action::VerticalSplit)?;
51+ let first = &args.files[0]; // we know it's not empty
52+ if first.is_dir() {
53+ editor.new_file(Action::VerticalSplit);
54+ compositor.push(Box::new(ui::file_picker(first.clone())));
55+ } else {
56+ for file in args.files {
57+ if file.is_dir() {
58+ return Err(anyhow::anyhow!(
59+ "expected a path to file, found a directory. (to open a directory pass it as first argument)"
60+ ));
61+ } else {
62+ editor.open(file, Action::VerticalSplit)?;
63+ }
64+ }
5165 }
5266 } else {
5367 editor.new_file(Action::VerticalSplit);
5468 }
5569
56− compositor.push(Box::new(ui::EditorView::new()));
57−
5870 let mut app = Self {
5971 compositor,
6072 editor,