This commit is contained in:
Aleksey Kladov 2019-05-31 20:23:56 +03:00
parent e1bda6aeda
commit 2d773a46c9

View File

@ -452,8 +452,15 @@ impl<'a> PoolDispatcher<'a> {
None => return Ok(self),
Some(req) => req,
};
match req.cast::<R>() {
Ok((id, params)) => {
let (id, params) = match req.cast::<R>() {
Ok(it) => it,
Err(req) => {
self.req = Some(req);
return Ok(self);
}
};
self.res = Some(id);
// Real time requests block user typing, so we should react quickly to them.
// Currently this means that we try to cancel background jobs if we don't have
// a spare thread.
@ -469,9 +476,7 @@ impl<'a> PoolDispatcher<'a> {
let response = match f(world, params) {
Ok(resp) => RawResponse::ok::<R>(id, &resp),
Err(e) => match e.downcast::<LspError>() {
Ok(lsp_error) => {
RawResponse::err(id, lsp_error.code, lsp_error.message)
}
Ok(lsp_error) => RawResponse::err(id, lsp_error.code, lsp_error.message),
Err(e) => {
if is_canceled(&e) {
// FIXME: When https://github.com/Microsoft/vscode-languageserver-node/issues/457
@ -501,10 +506,6 @@ impl<'a> PoolDispatcher<'a> {
let task = Task::Respond(response);
sender.send(task).unwrap();
});
self.res = Some(id);
}
Err(req) => self.req = Some(req),
}
Ok(self)
}