Avoid spamming errors on files outside workspace

This commit is contained in:
Tad Hardesty 2020-05-23 15:22:32 -07:00
parent 78175f891f
commit 4c8171acec

View file

@ -472,15 +472,16 @@ impl<'a> Engine<'a> {
// normal path, when we have a workspace root & an environment loaded
let path = url_to_path(url)?;
let root = url_to_path(root)?;
let stripped = match path.strip_prefix(&root) {
Ok(path) => path,
Err(_) => return Err(invalid_request(format!("outside workspace: {}", url))),
};
let defines = match self.defines {
Some(ref d) => d,
None => return Err(invalid_request("no preprocessor history")),
};
let stripped = match path.strip_prefix(&root) {
Ok(path) => path,
Err(_) => "<outside workspace>".as_ref(),
};
let (real_file_id, mut preprocessor) = match self.context.get_file(&stripped) {
Some(id) => (id, defines.branch_at_file(id, &self.context)),
None => (FileId::default(), defines.branch_at_end(&self.context)),