diff --git a/src/autoload.rs b/src/autoload.rs index 8d65d9f87..d6a0c6308 100644 --- a/src/autoload.rs +++ b/src/autoload.rs @@ -100,35 +100,29 @@ pub fn resolve_command(&mut self, cmd: &wstr, env: &dyn Environment) -> Option { - crate::FLOGF!(autoload, "Loading from path with var: %ls", path); - // HACK: Ignore generated_completions until we tried the embedded assets - if path - .find("/generated_completions/".chars().collect::>()) - .is_some() - { - possible_path = Some(path); - } else { - return Some(AutoloadPath::Path(path)); - } - } - AutoloadResult::Loaded => return None, - AutoloadResult::Pending => return None, - AutoloadResult::None => (), - }; - } else { - match self.resolve_command_impl(cmd, &[]) { - AutoloadResult::Path(path) => { - crate::FLOGF!(autoload, "Loading from path with var: %ls", path); + match self.resolve_command_impl( + cmd, + env.get(self.env_var_name) + .as_ref() + .map(|var| var.as_list()) + .unwrap_or_default(), + ) { + AutoloadResult::Path(path) => { + crate::FLOGF!(autoload, "Loading from path with var: %ls", path); + // HACK: Ignore generated_completions until we tried the embedded assets + if path + .find("/generated_completions/".chars().collect::>()) + .is_some() + { + possible_path = Some(path); + } else { return Some(AutoloadPath::Path(path)); } - AutoloadResult::Loaded => return None, - AutoloadResult::Pending => return None, - AutoloadResult::None => (), - }; - } + } + AutoloadResult::Loaded => return None, + AutoloadResult::Pending => return None, + AutoloadResult::None => (), + }; // HACK: In cargo tests, this used to never load functions // It will hang for reasons unrelated to this.