@ -162,14 +162,19 @@ impl Application {
// Unset path to prevent accidentally saving to the original tutor file.
doc_mut ! ( editor ) . set_path ( None ) ;
} else if ! args . files . is_empty ( ) {
if args . open_cwd {
// NOTE: The working directory is already set to args.files[0] in main()
editor . new_file ( Action ::VerticalSplit ) ;
let picker = ui ::file_picker ( "." . into ( ) , & config . load ( ) . editor ) ;
let mut files_it = args . files . into_iter ( ) . peekable ( ) ;
// If the first file is a directory, skip it and open a picker
if let Some ( ( first , _ ) ) = files_it . next_if ( | ( p , _ ) | p . is_dir ( ) ) {
let picker = ui ::file_picker ( first , & config . load ( ) . editor ) ;
compositor . push ( Box ::new ( overlaid ( picker ) ) ) ;
} else {
let nr_of_files = args . files . len ( ) ;
for ( i , ( file , pos ) ) in args . files . into_iter ( ) . enumerate ( ) {
}
// If there are any more files specified, open them
if files_it . peek ( ) . is_some ( ) {
let mut nr_of_files = 0 ;
for ( file , pos ) in files_it {
nr_of_files + = 1 ;
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)"
@ -181,7 +186,7 @@ impl Application {
// option. If neither of those two arguments are passed
// in, just load the files normally.
let action = match args . split {
_ if i = = 0 = > Action ::VerticalSplit ,
_ if nr_of_files = = 1 = > Action ::VerticalSplit ,
Some ( Layout ::Vertical ) = > Action ::VerticalSplit ,
Some ( Layout ::Horizontal ) = > Action ::HorizontalSplit ,
None = > Action ::Load ,
@ -208,6 +213,8 @@ impl Application {
// does not affect views without pos since it is at the top
let ( view , doc ) = current ! ( editor ) ;
align_view ( doc , view , Align ::Center ) ;
} else {
editor . new_file ( Action ::VerticalSplit ) ;
}
} else if stdin ( ) . is_tty ( ) | | cfg! ( feature = "integration" ) {
editor . new_file ( Action ::VerticalSplit ) ;