@@ -162,14 +162,19 @@ impl Application {
162162 // Unset path to prevent accidentally saving to the original tutor file.
163163 doc_mut!(editor).set_path(None);
164164 } else if !args.files.is_empty() {
165− if args.open_cwd {
166− // NOTE: The working directory is already set to args.files[0] in main()
167− editor.new_file(Action::VerticalSplit);
168− let picker = ui::file_picker(".".into(), &config.load().editor);
165+ let mut files_it = args.files.into_iter().peekable();
166+
167+ // If the first file is a directory, skip it and open a picker
168+ if let Some((first, _)) = files_it.next_if(|(p, _)| p.is_dir()) {
169+ let picker = ui::file_picker(first, &config.load().editor);
169170 compositor.push(Box::new(overlaid(picker)));
170− } else {
171− let nr_of_files = args.files.len();
172− for (i, (file, pos)) in args.files.into_iter().enumerate() {
171+ }
172+
173+ // If there are any more files specified, open them
174+ if files_it.peek().is_some() {
175+ let mut nr_of_files = 0;
176+ for (file, pos) in files_it {
177+ nr_of_files += 1;
173178 if file.is_dir() {
174179 return Err(anyhow::anyhow!(
175180 "expected a path to file, found a directory. (to open a directory pass it as first argument)"
@@ -181,7 +186,7 @@ impl Application {
181186 // option. If neither of those two arguments are passed
182187 // in, just load the files normally.
183188 let action = match args.split {
184− _ if i == 0 => Action::VerticalSplit,
189+ _ if nr_of_files == 1 => Action::VerticalSplit,
185190 Some(Layout::Vertical) => Action::VerticalSplit,
186191 Some(Layout::Horizontal) => Action::HorizontalSplit,
187192 None => Action::Load,
@@ -208,6 +213,8 @@ impl Application {
208213 // does not affect views without pos since it is at the top
209214 let (view, doc) = current!(editor);
210215 align_view(doc, view, Align::Center);
216+ } else {
217+ editor.new_file(Action::VerticalSplit);
211218 }
212219 } else if stdin().is_tty() || cfg!(feature = "integration") {
213220 editor.new_file(Action::VerticalSplit);