@ -122,12 +122,17 @@ FLAGS:
}
}
// NOTE: Set the working directory early so the correct configuration is loaded. Be aware that
// NOTE: Set the working directory early so the correct configuration is loaded. Be aware that
// Application::new() depends on this logic so it must be updated if this changes.
// Application::new() depends on this logic so it must be updated if this changes.
if let Some ( path ) = & args . working_directory {
let first_arg = args . files . first ( ) ;
helix_stdx ::env ::set_current_working_dir ( path ) ? ;
let cwd_changed = if let Some ( path ) = & args . working_directory {
} else if let Some ( ( path , _ ) ) = args . files . first ( ) . filter ( | p | p . 0. is_dir ( ) ) {
helix_stdx ::env ::set_current_working_dir ( path , false ) ? ;
true
} else if let Some ( ( path , _ ) ) = first_arg . filter ( | p | p . 0. is_dir ( ) ) {
// If the first file is a directory, it will be the working directory unless -w was specified
// If the first file is a directory, it will be the working directory unless -w was specified
helix_stdx ::env ::set_current_working_dir ( path ) ? ;
helix_stdx ::env ::set_current_working_dir ( path , false ) ? ;
}
true
} else {
false
} ;
let config = match Config ::load_default ( ) {
let config = match Config ::load_default ( ) {
Ok ( config ) = > config ,
Ok ( config ) = > config ,
@ -144,6 +149,12 @@ FLAGS:
}
}
} ;
} ;
if let Some ( ( path , _ ) ) = first_arg {
if ! cwd_changed & & config . editor . first_file_sets_work_dir {
helix_stdx ::env ::set_current_working_dir ( path , true ) ? ;
}
}
let lang_loader = helix_core ::config ::user_lang_loader ( ) . unwrap_or_else ( | err | {
let lang_loader = helix_core ::config ::user_lang_loader ( ) . unwrap_or_else ( | err | {
eprintln! ( "{}" , err ) ;
eprintln! ( "{}" , err ) ;
eprintln! ( "Press <ENTER> to continue with default language config" ) ;
eprintln! ( "Press <ENTER> to continue with default language config" ) ;