editor: Fix flaky navigation test (#17087)

Thorsten Ball and Kirill created

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 <kirill@zed.dev>

Change summary

crates/editor/src/editor.rs | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

Detailed changes

crates/editor/src/editor.rs 🔗

@@ -9111,18 +9111,16 @@ impl Editor {
         cx: &mut ViewContext<Self>,
     ) -> Task<Result<Navigated>> {
         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)
         })
     }