From 91462af546619740c93181b88a7908e481e6d6ab Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 6 Apr 2021 19:02:22 +0900 Subject: Allow starting hx without a file. A new blank file will be created. --- helix-term/src/application.rs | 11 +++++++---- helix-term/src/main.rs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 53fd086b..396bd565 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -45,14 +45,17 @@ pub struct Application { impl Application { pub fn new(mut args: Args, executor: &'static smol::Executor<'static>) -> Result { + use helix_view::editor::Action; let mut compositor = Compositor::new()?; let size = compositor.size(); let mut editor = Editor::new(executor, size); - let files = args.values_of_t::("files").unwrap(); - for file in files { - use helix_view::editor::Action; - editor.open(file, Action::HorizontalSplit)?; + if let Ok(files) = args.values_of_t::("files") { + for file in files { + editor.open(file, Action::HorizontalSplit)?; + } + } else { + editor.new_file(Action::HorizontalSplit)?; } compositor.push(Box::new(ui::EditorView::new())); diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 33792947..a2ea5993 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -56,7 +56,7 @@ fn main() { .arg( Arg::new("files") .about("Sets the input file to use") - .required(true) + .required(false) .multiple(true) .index(1), ) -- cgit v1.2.3-70-g09d2