From 4bc1d775358f8af756740c4ef5d250ceee560cb2 Mon Sep 17 00:00:00 2001 From: Julia Date: Fri, 2 Dec 2022 16:09:37 -0500 Subject: [PATCH] Fix tab following order test to wait for file open to propagate Now it can actually repro the original bug Co-Authored-By: Max Brunsfeld --- crates/collab/src/integration_tests.rs | 18 ++++++++++-------- crates/editor/src/items.rs | 6 ++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index 7115ed6c60ce40ad2c004e47214e54c677a45f0c..0daa3b69f6f7f2564616449bb9b1f586be4f5651 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -5040,14 +5040,6 @@ async fn test_following_tab_order( //Verify that the tabs opened in the order we expect assert_eq!(&pane_paths(&pane_a, cx_a), &["1.txt", "3.txt"]); - //Open just 2 on client B - workspace_b - .update(cx_b, |workspace, cx| { - workspace.open_path((worktree_id, "2.txt"), None, true, cx) - }) - .await - .unwrap(); - //Follow client B as client A workspace_a .update(cx_a, |workspace, cx| { @@ -5058,6 +5050,15 @@ async fn test_following_tab_order( .await .unwrap(); + //Open just 2 on client B + workspace_b + .update(cx_b, |workspace, cx| { + workspace.open_path((worktree_id, "2.txt"), None, true, cx) + }) + .await + .unwrap(); + deterministic.run_until_parked(); + // Verify that newly opened followed file is at the end assert_eq!(&pane_paths(&pane_a, cx_a), &["1.txt", "3.txt", "2.txt"]); @@ -5069,6 +5070,7 @@ async fn test_following_tab_order( .await .unwrap(); assert_eq!(&pane_paths(&pane_b, cx_b), &["2.txt", "1.txt"]); + deterministic.run_until_parked(); // Verify that following into 1 did not reorder assert_eq!(&pane_paths(&pane_a, cx_a), &["1.txt", "3.txt", "2.txt"]); diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 0cc8575e99156d85366cc3aaec442913b36dd6a4..ccabe81de6cf96cff98b92e52127128b4011ca1b 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -55,9 +55,11 @@ impl FollowableItem for Editor { let buffer = buffer.await?; let editor = pane .read_with(&cx, |pane, cx| { - pane.items_of_type::().find(|editor| { + let existing = pane.items_of_type::().find(|editor| { editor.read(cx).buffer.read(cx).as_singleton().as_ref() == Some(&buffer) - }) + }); + dbg!(&existing); + existing }) .unwrap_or_else(|| { pane.update(&mut cx, |_, cx| {