Silence "file out of workspace" errors

We really should fix this limitation of the VFS, but it's some way off
at the moment, so let's just silence the user-visible error for now.
This commit is contained in:
Aleksey Kladov
2020-03-09 10:54:14 +01:00
parent 58ab084034
commit 43bc03faf0
2 changed files with 12 additions and 3 deletions

View File

@@ -44,6 +44,8 @@ pub struct LspError {
}
impl LspError {
pub const UNKNOWN_FILE: i32 = -32900;
pub fn new(code: i32, message: String) -> LspError {
LspError { code, message }
}
@@ -805,7 +807,14 @@ where
let response = match result {
Ok(resp) => Response::new_ok(id, &resp),
Err(e) => match e.downcast::<LspError>() {
Ok(lsp_error) => Response::new_err(id, lsp_error.code, lsp_error.message),
Ok(lsp_error) => {
if lsp_error.code == LspError::UNKNOWN_FILE {
// Work-around for https://github.com/rust-analyzer/rust-analyzer/issues/1521
Response::new_ok(id, ())
} else {
Response::new_err(id, lsp_error.code, lsp_error.message)
}
}
Err(e) => {
if is_canceled(&e) {
Response::new_err(