diff options
author | wojciechkepka | 2021-06-02 14:20:41 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-04 02:02:06 +0000 |
commit | 43b92b24d2ed421625ff77c3a09a7909f7d82e02 (patch) | |
tree | 500217fa075cde709d7c3f87bb0e3df590701e20 /helix-term/src | |
parent | b2b2d430ae4af8b33d5bb920316a1165f8b3ba45 (diff) |
Show file picker when directory passed as first arg
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/application.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 5ea6be2b..f064e866 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -45,16 +45,28 @@ impl Application { let size = compositor.size(); let mut editor = Editor::new(size); + compositor.push(Box::new(ui::EditorView::new())); + if !args.files.is_empty() { - for file in args.files { - editor.open(file, Action::VerticalSplit)?; + let first = &args.files[0]; // we know it's not empty + if first.is_dir() { + editor.new_file(Action::VerticalSplit); + compositor.push(Box::new(ui::file_picker(first.clone()))); + } else { + for file in args.files { + if file.is_dir() { + return Err(anyhow::anyhow!( + "expected a path to file, found a directory. (to open a directory pass it as first argument)" + )); + } else { + editor.open(file, Action::VerticalSplit)?; + } + } } } else { editor.new_file(Action::VerticalSplit); } - compositor.push(Box::new(ui::EditorView::new())); - let mut app = Self { compositor, editor, |