From 4c8171acec82dbe2b910f7264eed8a488c0c5d21 Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Sat, 23 May 2020 15:22:32 -0700 Subject: [PATCH] Avoid spamming errors on files outside workspace --- src/langserver/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/langserver/main.rs b/src/langserver/main.rs index 0594cc93..62dfbd9c 100644 --- a/src/langserver/main.rs +++ b/src/langserver/main.rs @@ -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(_) => "".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)),