From 4f1728e5ee0bb7f9981d3d8e5dd702728e1ff48e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 31 May 2025 13:10:15 +0300 Subject: [PATCH] Do not unwrap when updating inline diagnostics (#31814) Also do not hold the strong editor reference while debounced. Release Notes: - N/A --- crates/editor/src/editor.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 8276992734..dfd526b7e8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -15703,15 +15703,14 @@ impl Editor { None }; self.inline_diagnostics_update = cx.spawn_in(window, async move |editor, cx| { - let editor = editor.upgrade().unwrap(); - if let Some(debounce) = debounce { cx.background_executor().timer(debounce).await; } - let Some(snapshot) = editor - .update(cx, |editor, cx| editor.buffer().read(cx).snapshot(cx)) - .ok() - else { + let Some(snapshot) = editor.upgrade().and_then(|editor| { + editor + .update(cx, |editor, cx| editor.buffer().read(cx).snapshot(cx)) + .ok() + }) else { return; };