Use relative paths as file-relative when parsing a file (#6150)

* Make function local (not used anywhere else)

* Use path relative to the parsed file

* Do not use real cwd at all
This commit is contained in:
Jakub Žádník
2022-07-27 18:36:56 +03:00
committed by GitHub
parent 8bd6b5b913
commit c92211c016
7 changed files with 277 additions and 42 deletions

View File

@ -729,6 +729,14 @@ impl EngineState {
self.num_files() - 1
}
pub fn get_cwd(&self) -> Option<String> {
if let Some(pwd_value) = self.get_env_var(PWD_ENV) {
pwd_value.as_string().ok()
} else {
None
}
}
#[cfg(not(windows))]
pub fn get_sig_quit(&self) -> &Option<Arc<AtomicBool>> {
&self.sig_quit
@ -755,6 +763,8 @@ pub struct StateWorkingSet<'a> {
pub delta: StateDelta,
pub external_commands: Vec<Vec<u8>>,
pub type_scope: TypeScope,
/// Current working directory relative to the file being parsed right now
pub currently_parsed_cwd: Option<PathBuf>,
}
/// A temporary placeholder for expression types. It is used to keep track of the input types
@ -927,6 +937,7 @@ impl<'a> StateWorkingSet<'a> {
permanent_state,
external_commands: vec![],
type_scope: TypeScope::default(),
currently_parsed_cwd: None,
}
}