From a8574805617d86304232b47d84fd7c7f4f773520 Mon Sep 17 00:00:00 2001 From: Bjorn Ove Hay Andersen Date: Mon, 9 Oct 2023 18:38:09 +0200 Subject: Set the working directory before loading the config (#8498) --- helix-term/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'helix-term/src/main.rs') diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 009cbf7f..ed3478ac 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -115,6 +115,14 @@ FLAGS: setup_logging(args.verbosity).context("failed to initialize logging")?; + // 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. + if let Some((path, true)) = args.files.first().map(|(path, _)| (path, path.is_dir())) { + helix_loader::set_current_working_dir(path)?; + } else if let Some(path) = &args.working_directory { + helix_loader::set_current_working_dir(path)?; + } + let config = match Config::load_default() { Ok(config) => config, Err(ConfigLoadError::Error(err)) if err.kind() == std::io::ErrorKind::NotFound => { -- cgit v1.2.3-70-g09d2