From a012d731ee74304d70619d8c4f66bc405a539b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 3 Jan 2023 18:13:21 +0100 Subject: [PATCH] fix(lsp): don't error if completionItem/resolve request fails (#17250) --- cli/lsp/language_server.rs | 43 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 3e08f5ad4c..f44f8e0711 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1959,28 +1959,31 @@ impl Inner { if let Some(data) = &data.tsc { let specifier = &data.specifier; let req = tsc::RequestMethod::GetCompletionDetails(data.into()); - let maybe_completion_info: Option = - self.ts_server.request(self.snapshot(), req).await.map_err( - |err| { - error!("Unable to get completion info from TypeScript: {}", err); - LspError::internal_error() - }, - )?; - if let Some(completion_info) = maybe_completion_info { - completion_info - .as_completion_item(¶ms, data, specifier, self) - .map_err(|err| { + let result: Result, _> = + self.ts_server.request(self.snapshot(), req).await; + match result { + Ok(maybe_completion_info) => { + if let Some(completion_info) = maybe_completion_info { + completion_info + .as_completion_item(¶ms, data, specifier, self) + .map_err(|err| { + error!( + "Failed to serialize virtual_text_document response: {}", + err + ); + LspError::internal_error() + })? + } else { error!( - "Failed to serialize virtual_text_document response: {}", - err + "Received an undefined response from tsc for completion details." ); - LspError::internal_error() - })? - } else { - error!( - "Received an undefined response from tsc for completion details." - ); - params + params + } + } + Err(err) => { + error!("Unable to get completion info from TypeScript: {}", err); + return Ok(params); + } } } else if let Some(url) = data.documentation { CompletionItem {