From 316e19ce94883de40567fe0f85947916eed3fc35 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 22 Jun 2023 22:11:10 +0300 Subject: [PATCH] Remove stale cancelled inlay hints workaround --- crates/editor/src/inlay_hint_cache.rs | 2 +- crates/project/src/project.rs | 24 ++++-------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rs index a62706bb7f387ad63cc157cff1582daa3c60d6f8..9044c6f5095513f26eb68d6a651440445b38d459 100644 --- a/crates/editor/src/inlay_hint_cache.rs +++ b/crates/editor/src/inlay_hint_cache.rs @@ -523,7 +523,7 @@ fn hints_fetch_task( return Ok(None); }; Ok(match task { - Some(task) => task.await.context("inlays for buffer task")?, + Some(task) => Some(task.await.context("inlays for buffer task")?), None => Some(Vec::new()), }) }) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 5da143f602d206ce9a6fd738ab1dcdcef5797662..a248086494ec0910561ae9123a8cfe0f3fb423f8 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -4934,7 +4934,7 @@ impl Project { buffer_handle: ModelHandle, range: Range, cx: &mut ModelContext, - ) -> Task>>> { + ) -> Task>> { let buffer = buffer_handle.read(cx); let range = buffer.anchor_before(range.start)..buffer.anchor_before(range.end); let range_start = range.start; @@ -4952,11 +4952,7 @@ impl Project { }) .await .context("waiting for inlay hint request range edits")?; - match lsp_request_task.await { - Ok(hints) => Ok(Some(hints)), - Err(e) if is_content_modified_error(&e) => Ok(None), - Err(other_e) => Err(other_e).context("inlay hints LSP request"), - } + lsp_request_task.await.context("inlay hints LSP request") }) } else if let Some(project_id) = self.remote_id() { let client = self.client.clone(); @@ -4981,13 +4977,7 @@ impl Project { ) .await; - match hints_request_result { - Ok(hints) => Ok(Some(hints)), - Err(e) if is_content_modified_error(&e) => Ok(None), - Err(other_err) => { - Err(other_err).context("inlay hints proto response conversion") - } - } + hints_request_result.context("inlay hints proto response conversion") }) } else { Task::ready(Err(anyhow!("project does not have a remote id"))) @@ -6779,8 +6769,7 @@ impl Project { project.inlay_hints(buffer, start..end, cx) }) .await - .context("inlay hints fetch")? - .unwrap_or_default(); + .context("inlay hints fetch")?; Ok(this.update(&mut cx, |project, cx| { InlayHints::response_to_proto(buffer_hints, project, sender_id, &buffer_version, cx) @@ -7855,8 +7844,3 @@ async fn wait_for_loading_buffer( receiver.next().await; } } - -// TODO kb what are better ways? -fn is_content_modified_error(error: &anyhow::Error) -> bool { - format!("{error:#}").contains("content modified") -}