From 376828e92f6aa4c446f9053cc676cb46a2d06162 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Thu, 29 Aug 2024 17:00:28 +0200 Subject: [PATCH] editor: Fix flaky navigation test (#17087) This test was flaky because both tasks were started at the same time and the first one that would win, would navigate the editor. Now the order is fixed, because the second task is only spawned after the first one. Release Notes: - N/A --------- Co-authored-by: Kirill --- crates/editor/src/editor.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 07fd3764320296f98ffb08a17086cdec6c021528..ff866bf11747fd20cc20a7d1c449da35a575c63f 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -9111,18 +9111,16 @@ impl Editor { cx: &mut ViewContext, ) -> Task> { let definition = self.go_to_definition_of_kind(GotoDefinitionKind::Symbol, false, cx); - let references = self.find_all_references(&FindAllReferences, cx); - cx.background_executor().spawn(async move { + cx.spawn(|editor, mut cx| async move { if definition.await? == Navigated::Yes { return Ok(Navigated::Yes); } - if let Some(references) = references { - if references.await? == Navigated::Yes { - return Ok(Navigated::Yes); - } + match editor.update(&mut cx, |editor, cx| { + editor.find_all_references(&FindAllReferences, cx) + })? { + Some(references) => references.await, + None => Ok(Navigated::No), } - - Ok(Navigated::No) }) }